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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#![recursion_limit = "128"]

#[macro_use]
extern crate log;
#[macro_use]
extern crate quick_error;
mod bearer_token_client;
mod blob_sas_builder;
pub mod client;
mod client_endpoint;
mod connection_string;
mod connection_string_builder;
mod container_sas_builder;
mod hyper_client_endpoint;
mod into_azure_path;
pub mod key_client;
pub mod prelude;
mod rest_client;
pub mod shared_access_signature;
pub use self::connection_string::{ConnectionString, EndpointProtocol};
pub use self::connection_string_builder::ConnectionStringBuilder;
pub use self::into_azure_path::IntoAzurePath;
pub use self::rest_client::{
    get_default_json_mime, get_json_mime_fullmetadata, get_json_mime_nometadata, perform_request,
    ServiceType,
};
use crate::key_client::KeyClient;
use azure_sdk_core::errors::AzureError;
use azure_sdk_core::headers::COPY_ID;
use azure_sdk_core::util::HeaderMapExt;
pub use client::Client;
pub use client_endpoint::ClientEndpoint;
use http::HeaderMap;
pub use hyper_client_endpoint::HyperClientEndpoint;

pub trait ClientRequired<'a, C>
where
    C: Client,
{
    fn client(&self) -> &'a C;
}

pub trait KeyClientRequired<'a> {
    fn key_client(&self) -> &'a KeyClient;
}

pub trait SharedAccessSignatureSupport<'a> {
    type O;
    fn with_shared_access_signature(
        self,
        signature: &'a shared_access_signature::SharedAccessSignature,
    ) -> Self::O;
}

pub trait SharedAccessSignatureRequired<'a> {
    fn shared_access_signature(&self) -> &'a shared_access_signature::SharedAccessSignature;
}

#[derive(Debug, Clone, PartialEq)]
pub struct IPRange {
    pub start: std::net::IpAddr,
    pub end: std::net::IpAddr,
}

pub type CopyId = uuid::Uuid;

pub fn copy_id_from_headers(headers: &HeaderMap) -> Result<CopyId, AzureError> {
    let copy_id = headers
        .get_as_str(COPY_ID)
        .ok_or_else(|| AzureError::HeaderNotFound(COPY_ID.to_owned()))?;
    Ok(uuid::Uuid::parse_str(copy_id)?)
}