azure_core/request_options/
content_length.rs

1use crate::headers::{self, Header};
2
3#[derive(Debug, Clone, Copy)]
4pub struct ContentLength(i32);
5
6impl ContentLength {
7    pub fn new(count: i32) -> Self {
8        Self(count)
9    }
10}
11
12impl Header for ContentLength {
13    fn name(&self) -> headers::HeaderName {
14        headers::CONTENT_LENGTH
15    }
16
17    fn value(&self) -> headers::HeaderValue {
18        let count = if self.0 < 0 { -1 } else { self.0 };
19        format!("{count}").into()
20    }
21}