mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2025-12-31 08:33:44 +01:00
fix(version-up): check-in of latest sources
This also includes crate files to remember which crates we have published already. Related to #44
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// COPY OF 'src/rust/cmn.rs'
|
||||
// COPY OF 'src/rust/api/cmn.rs'
|
||||
// DO NOT EDIT
|
||||
use std::marker::MarkerTrait;
|
||||
use std::io::{self, Read, Seek, Cursor, Write, SeekFrom};
|
||||
@@ -24,7 +24,7 @@ use serde;
|
||||
pub trait Hub: MarkerTrait {}
|
||||
|
||||
/// Identifies types for building methods of a particular resource type
|
||||
pub trait ResourceMethodsBuilder: MarkerTrait {}
|
||||
pub trait MethodsBuilder: MarkerTrait {}
|
||||
|
||||
/// Identifies types which represent builders for a particular resource method
|
||||
pub trait CallBuilder: MarkerTrait {}
|
||||
@@ -105,12 +105,15 @@ pub trait Delegate {
|
||||
/// information if he is interesting in knowing more context when further calls to it
|
||||
/// are made.
|
||||
/// The matching `finished()` call will always be made, no matter whether or not the API
|
||||
/// request was sucessfull. That way, the delgate may easily maintain a clean state
|
||||
/// request was successful. That way, the delegate may easily maintain a clean state
|
||||
/// between various API calls.
|
||||
fn begin(&mut self, MethodInfo) {}
|
||||
|
||||
/// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), usually if there are network problems.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
///
|
||||
/// Return retry information.
|
||||
fn http_error(&mut self, &hyper::HttpError) -> Retry {
|
||||
Retry::Abort
|
||||
@@ -133,7 +136,7 @@ pub trait Delegate {
|
||||
/// Called during resumable uploads to provide a URL for the impending upload.
|
||||
/// It was saved after a previous call to `store_upload_url(...)`, and if not None,
|
||||
/// will be used instead of asking the server for a new upload URL.
|
||||
/// This is useful in case a previous resumable upload was aborted/cancelled, but should now
|
||||
/// This is useful in case a previous resumable upload was aborted/canceled, but should now
|
||||
/// be resumed.
|
||||
/// The returned URL will be used exactly once - if it fails again and the delegate allows
|
||||
/// to retry, we will ask the server for a new upload URL.
|
||||
@@ -154,8 +157,8 @@ pub trait Delegate {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// `json_decode_error` - The decoder error
|
||||
/// * `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// * `json_decode_error` - The decoder error
|
||||
fn response_json_decode_error(&mut self, json_encoded_value: &str, json_decode_error: &serde::json::Error) {
|
||||
let _ = json_encoded_value;
|
||||
let _ = json_decode_error;
|
||||
@@ -166,6 +169,9 @@ pub trait Delegate {
|
||||
/// depends on the used API method.
|
||||
/// The delegate should check the status, header and decoded json error to decide
|
||||
/// whether to retry or not. In the latter case, the underlying call will fail.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>) -> Retry {
|
||||
Retry::Abort
|
||||
}
|
||||
@@ -197,8 +203,8 @@ pub trait Delegate {
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
/// * `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
fn finished(&mut self, is_success: bool) {
|
||||
let _ = is_success;
|
||||
}
|
||||
@@ -212,8 +218,8 @@ pub struct DefaultDelegate;
|
||||
impl Delegate for DefaultDelegate {}
|
||||
|
||||
|
||||
/// A universal result type used as return for all action method results.
|
||||
pub enum Result<T = ()> {
|
||||
|
||||
pub enum Error {
|
||||
/// The http connection failed
|
||||
HttpError(hyper::HttpError),
|
||||
|
||||
@@ -240,11 +246,11 @@ pub enum Result<T = ()> {
|
||||
|
||||
/// Indicates an HTTP repsonse with a non-success status code
|
||||
Failure(hyper::client::Response),
|
||||
|
||||
/// It worked !
|
||||
Success(T),
|
||||
}
|
||||
|
||||
/// A universal result type used as return for all calls.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Contains information about an API request.
|
||||
pub struct MethodInfo {
|
||||
pub id: &'static str,
|
||||
@@ -499,7 +505,7 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
where NC: hyper::net::NetworkConnector,
|
||||
A: oauth2::GetToken {
|
||||
|
||||
fn query_transfer_status(&mut self) -> (Option<u64>, hyper::HttpResult<hyper::client::Response>) {
|
||||
fn query_transfer_status(&mut self) -> std::result::Result<u64, hyper::HttpResult<hyper::client::Response>> {
|
||||
loop {
|
||||
match self.client.post(self.url)
|
||||
.header(UserAgent(self.user_agent.to_string()))
|
||||
@@ -516,17 +522,17 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return (None, Ok(r))
|
||||
return Err(Ok(r))
|
||||
}
|
||||
};
|
||||
return (Some(h.0.last), Ok(r))
|
||||
return Ok(h.0.last)
|
||||
}
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return (None, Err(err))
|
||||
return Err(Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,8 +545,8 @@ impl<'a, NC, A> ResumableUploadHelper<'a, NC, A>
|
||||
let mut start = match self.start_at {
|
||||
Some(s) => s,
|
||||
None => match self.query_transfer_status() {
|
||||
(Some(s), _) => s,
|
||||
(_, result) => return Some(result)
|
||||
Ok(s) => s,
|
||||
Err(result) => return Some(result)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user