azure_core/request_options/
max_item_count.rs
1use crate::headers::{self, Header};
2
3#[derive(Debug, Clone, Copy)]
5pub struct MaxItemCount(i32);
6
7impl MaxItemCount {
8 pub fn new(count: i32) -> Self {
10 Self(count)
11 }
12}
13
14impl Header for MaxItemCount {
15 fn name(&self) -> headers::HeaderName {
16 headers::MAX_ITEM_COUNT
17 }
18
19 fn value(&self) -> headers::HeaderValue {
20 let count = if self.0 <= 0 { -1 } else { self.0 };
21 format!("{count}").into()
22 }
23}
24
25impl From<i32> for MaxItemCount {
26 fn from(count: i32) -> Self {
27 Self::new(count)
28 }
29}
30
31impl Default for MaxItemCount {
32 fn default() -> Self {
33 MaxItemCount::new(-1)
34 }
35}