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
#[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()
})
}