azure_core/request_options/
source_lease_id.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::headers::{self, Header};
use std::str::FromStr;
use uuid::Uuid;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SourceLeaseId(Uuid);

impl std::fmt::Display for SourceLeaseId {
    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
        self.0.fmt(fmt)
    }
}

impl std::str::FromStr for SourceLeaseId {
    type Err = <Uuid as FromStr>::Err;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Ok(Self(uuid::Uuid::from_str(s)?))
    }
}

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

    fn value(&self) -> headers::HeaderValue {
        self.0.to_string().into()
    }
}