azure_core/request_options/
content_length.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::headers::{self, Header};

#[derive(Debug, Clone, Copy)]
pub struct ContentLength(i32);

impl ContentLength {
    pub fn new(count: i32) -> Self {
        Self(count)
    }
}

impl Header for ContentLength {
    fn name(&self) -> headers::HeaderName {
        headers::CONTENT_LENGTH
    }

    fn value(&self) -> headers::HeaderValue {
        let count = if self.0 < 0 { -1 } else { self.0 };
        format!("{count}").into()
    }
}