azure_core/request_options/
lease.rs
1use crate::headers::{self, Header};
2use std::str::FromStr;
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct LeaseId(Uuid);
7
8impl std::fmt::Display for LeaseId {
9 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
10 self.0.fmt(fmt)
11 }
12}
13
14impl From<Uuid> for LeaseId {
15 fn from(value: Uuid) -> Self {
16 Self(value)
17 }
18}
19
20impl std::str::FromStr for LeaseId {
21 type Err = <Uuid as FromStr>::Err;
22
23 fn from_str(s: &str) -> Result<Self, Self::Err> {
24 Ok(Self(uuid::Uuid::from_str(s)?))
25 }
26}
27
28impl Header for LeaseId {
29 fn name(&self) -> headers::HeaderName {
30 headers::LEASE_ID
31 }
32
33 fn value(&self) -> headers::HeaderValue {
34 format!("{}", self.0).into()
35 }
36}