#[macro_use(Deserialize)]
extern crate serde;
#[macro_use(Fail)]
extern crate failure;
pub mod error;
pub mod objects;
mod response;
pub mod types;
pub extern crate http;
pub use response::{ApiResponse, Response};
pub use types::{BucketName, ObjectName};
pub enum Scopes {
ReadOnly,
ReadWrite,
FullControl,
CloudPlatformReadOnly,
CloudPlatform,
}
impl AsRef<str> for Scopes {
fn as_ref(&self) -> &str {
match *self {
Scopes::ReadOnly => "https://www.googleapis.com/auth/devstorage.read_only",
Scopes::ReadWrite => "https://www.googleapis.com/auth/devstorage.read_write",
Scopes::FullControl => "https://www.googleapis.com/auth/devstorage.full_control",
Scopes::CloudPlatformReadOnly => {
"https://www.googleapis.com/auth/cloud-platform.read-only"
}
Scopes::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
}
}
}
fn get_content_length(headers: &http::HeaderMap) -> Option<usize> {
headers.get(http::header::CONTENT_LENGTH).and_then(|h| {
h.to_str()
.map_err(|_| ())
.and_then(|hv| hv.parse::<u64>().map(|l| l as usize).map_err(|_| ()))
.ok()
})
}