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
use hyper::header::Headers; use hyper::client::response::Response; use hyper::error::Error; use std::io::Read; use azure::core::{HTTPMethod, perform_request}; #[derive(Debug)] pub struct Client { account: String, key: String, use_https: bool, } impl Client { pub fn new(account: &str, key: &str, use_https: bool) -> Client { Client { account: account.to_owned(), key: key.to_owned(), use_https: use_https, } } pub fn account(&self) -> &str { &self.account } pub fn use_https(&self) -> bool { self.use_https } pub fn auth_scheme(&self) -> &'static str { if self.use_https { "https" } else { "http" } } pub fn key(&self) -> &str { &self.key } pub fn perform_request(&self, uri: &str, method: HTTPMethod, headers: &Headers, request_body: Option<(&mut Read, u64)>) -> Result<Response, Error> { perform_request(uri, method, &self.key, headers, request_body) } }