mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-06 11:34:34 +01:00
fix(rustup): use std::Thread::sleep
However, in sibling libraries, we still use time::Duration, which now is a part of std::time::Duration. These should be adjusted, to make the usage of sleep(Duration::from_millis(d.num_milliseconds() as u64)) into sleep(d)
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
<%namespace name="rbuild" file="lib/rbuild.mako"/>\
|
||||
<%namespace name="mbuild" file="lib/mbuild.mako"/>\
|
||||
<%namespace name="schema" file="lib/schema.mako"/>\
|
||||
<%
|
||||
from util import (new_context, rust_comment, rust_doc_comment, rust_module_doc_comment,
|
||||
rb_type, hub_type, mangle_ident, hub_type_params_s, hub_type_bounds,
|
||||
<%
|
||||
from util import (new_context, rust_comment, rust_doc_comment, rust_module_doc_comment,
|
||||
rb_type, hub_type, mangle_ident, hub_type_params_s, hub_type_bounds,
|
||||
rb_type_params_s, find_fattest_resource, HUB_TYPE_PARAMETERS, METHODS_RESOURCE,
|
||||
UNUSED_TYPE_MARKER, schema_markers)
|
||||
|
||||
@@ -36,10 +36,11 @@ use std::collections::BTreeMap;
|
||||
use serde_json as json;
|
||||
use std::io;
|
||||
use std::fs;
|
||||
use std::thread::sleep_ms;
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part,
|
||||
ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder,
|
||||
ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder,
|
||||
Resource, ErrorResponse, remove_json_null_values};
|
||||
|
||||
|
||||
@@ -131,4 +132,4 @@ ${rbuild.new(resource, c)}
|
||||
${mbuild.new(resource, method, c)}
|
||||
|
||||
% endfor ## method in methods
|
||||
% endfor ## resource, methods
|
||||
% endfor ## resource, methods
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
from util import (put_and, rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment,
|
||||
rb_type, mb_type, singular, hub_type, to_fqan, indent_all_but_first_by,
|
||||
method_params, activity_rust_type, mangle_ident, activity_input_type, get_word,
|
||||
split_camelcase_s, property, is_pod_property, TREF, IO_REQUEST,
|
||||
split_camelcase_s, property, is_pod_property, TREF, IO_REQUEST,
|
||||
schema_to_required_property, rust_copy_value_s, is_required_property,
|
||||
hide_rust_doc_test, build_all_params, REQUEST_VALUE_PROPERTY_NAME, organize_params,
|
||||
hide_rust_doc_test, build_all_params, REQUEST_VALUE_PROPERTY_NAME, organize_params,
|
||||
indent_by, to_rust_type, rnd_arg_val_for_type, extract_parts, mb_type_params_s,
|
||||
hub_type_params_s, method_media_params, enclose_in, mb_type_bounds, method_response,
|
||||
CALL_BUILDER_MARKERT_TRAIT, pass_through, markdown_rust_block, parts_from_params,
|
||||
@@ -19,7 +19,7 @@
|
||||
return extract_parts(part_prop.get('description', ''))
|
||||
|
||||
def make_parts_desc(part_prop):
|
||||
|
||||
|
||||
parts = get_parts(part_prop)
|
||||
if not parts:
|
||||
return None
|
||||
@@ -35,7 +35,7 @@
|
||||
###############################################################################################
|
||||
###############################################################################################
|
||||
<%def name="new(resource, method, c)">\
|
||||
<%
|
||||
<%
|
||||
hub_type_name = hub_type(schemas,util.canonical_name())
|
||||
m = c.fqan_map[to_fqan(c.rtc_map[resource], resource, method)]
|
||||
response_schema = method_response(c, m)
|
||||
@@ -90,14 +90,14 @@ ${part_desc | rust_doc_comment}
|
||||
/// You will need authorization for \
|
||||
% if len(m.scopes) > 1:
|
||||
at least one of the following scopes to make a valid call, possibly depending on *parts*:
|
||||
///
|
||||
///
|
||||
% for s in m.scopes:
|
||||
/// * *${s}*
|
||||
% endfor
|
||||
% else:
|
||||
the *${m.scopes[0]}* scope to make a valid call.
|
||||
% endif # len(scopes) > 1
|
||||
///
|
||||
///
|
||||
/// The default scope will be `${scope_url_to_variant(name, method_default_scope(m), fully_qualified=True)}`.
|
||||
% endif # have scopes
|
||||
///
|
||||
@@ -142,13 +142,13 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
||||
% endfor
|
||||
|
||||
/// Set any additional parameter of the query string used in the request.
|
||||
/// It should be used to set parameters which are not yet available through their own
|
||||
/// It should be used to set parameters which are not yet available through their own
|
||||
/// setters.
|
||||
///
|
||||
/// Please note that this method must not be used to set any of the known paramters
|
||||
/// which have their own setter method. If done anyway, the request will fail.
|
||||
% if parameters:
|
||||
///
|
||||
///
|
||||
/// # Additional Parameters
|
||||
///
|
||||
% for opn, op in list((opn, op) for (opn, op) in parameters.iteritems() if opn not in [p.name for p in params]):
|
||||
@@ -163,17 +163,17 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
||||
|
||||
% if method_default_scope(m):
|
||||
/// Identifies the authorization scope for the method you are building.
|
||||
///
|
||||
///
|
||||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||||
/// `${scope_url_to_variant(name, method_default_scope(m), fully_qualified=True)}`.
|
||||
///
|
||||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||||
/// tokens for more than one scope.
|
||||
///
|
||||
///
|
||||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||||
/// sufficient, a read-write scope will do as well.
|
||||
pub fn ${ADD_SCOPE_FN}<T>(mut self, scope: T) -> ${ThisType}
|
||||
pub fn ${ADD_SCOPE_FN}<T>(mut self, scope: T) -> ${ThisType}
|
||||
where T: AsRef<str> {
|
||||
self.${api.properties.scopes}.insert(scope.as_ref().to_string(), ());
|
||||
self
|
||||
@@ -225,14 +225,14 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
||||
% endif
|
||||
% if show_part_info(m, p):
|
||||
///
|
||||
/// Even though the *parts* list is automatically derived from *Resource* passed in
|
||||
/// Even though the *parts* list is automatically derived from *Resource* passed in
|
||||
/// during instantiation and indicates which values you are passing, the response would contain the very same parts.
|
||||
/// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in,
|
||||
/// like statistics that are generated server side. Therefore you should use this method to specify
|
||||
/// like statistics that are generated server side. Therefore you should use this method to specify
|
||||
/// the parts you provide in addition to the ones you want in the response.
|
||||
% elif is_required_property(p):
|
||||
///
|
||||
/// Even though the property as already been set when instantiating this call,
|
||||
/// Even though the property as already been set when instantiating this call,
|
||||
/// we provide this method for API completeness.
|
||||
% endif
|
||||
% if part_desc:
|
||||
@@ -459,7 +459,7 @@ match result {
|
||||
sn = s[1:-1]
|
||||
|
||||
# NOTE: We only handle the cases that are actually used in the schemas. If this shouldn't
|
||||
# be worth it anymore (i.e. too many cases), then we should use a uri-template library
|
||||
# be worth it anymore (i.e. too many cases), then we should use a uri-template library
|
||||
# to handle this at runtime, possibly, or use a python uri-template library, to more easily
|
||||
# handle the required cases. Whatever is less work, I guess.
|
||||
if sn.startswith('/') and sn.endswith('*'):
|
||||
@@ -490,7 +490,7 @@ match result {
|
||||
Some(d) => d,
|
||||
None => &mut dd
|
||||
};
|
||||
dlg.begin(MethodInfo { id: "${m.id}",
|
||||
dlg.begin(MethodInfo { id: "${m.id}",
|
||||
http_method: ${method_name_to_variant(m.httpMethod)} });
|
||||
let mut params: Vec<(&str, String)> = Vec::with_capacity((${len(params) + len(reserved_params)} + ${paddfields}.len()));
|
||||
<%
|
||||
@@ -571,7 +571,7 @@ match result {
|
||||
% endif ## response schema
|
||||
|
||||
% if media_params:
|
||||
let (mut url, upload_type) =
|
||||
let (mut url, upload_type) =
|
||||
% for mp in media_params:
|
||||
% if loop.first:
|
||||
if \
|
||||
@@ -582,8 +582,8 @@ protocol == "${mp.protocol}" {
|
||||
("${join_url(rootUrl, mp.path)}".to_string(), "${upload_type_map.get(mp.protocol, mp.protocol)}")
|
||||
} \
|
||||
% endfor
|
||||
else {
|
||||
unreachable!()
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
params.push(("uploadType", upload_type.to_string()));
|
||||
% else:
|
||||
@@ -591,7 +591,7 @@ else {
|
||||
% endif
|
||||
% if not default_scope:
|
||||
% if no_auth is UNDEFINED:
|
||||
<%
|
||||
<%
|
||||
assert 'key' in parameters, "Expected 'key' parameter if there are no scopes"
|
||||
%>
|
||||
let mut key = ${auth_call}.api_key();
|
||||
@@ -619,7 +619,7 @@ else {
|
||||
replace_init = ': Option<&str> = None'
|
||||
replace_assign = 'Some(value)'
|
||||
url_replace_arg = 'replace_with.expect("to find substitution value in params")'
|
||||
if URL_ENCODE in special_cases:
|
||||
if URL_ENCODE in special_cases:
|
||||
replace_init = ' = String::new()'
|
||||
replace_assign = 'value.to_string()'
|
||||
url_replace_arg = '&replace_with'
|
||||
@@ -652,7 +652,7 @@ else {
|
||||
}
|
||||
}
|
||||
% endif
|
||||
|
||||
|
||||
if params.len() > 0 {
|
||||
url.push('?');
|
||||
url.push_str(&url::form_urlencoded::serialize(params));
|
||||
@@ -660,7 +660,7 @@ else {
|
||||
|
||||
% if request_value:
|
||||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||||
let mut request_value_reader =
|
||||
let mut request_value_reader =
|
||||
{
|
||||
let mut value = json::value::to_value(&self.${property(REQUEST_VALUE_PROPERTY_NAME)});
|
||||
remove_json_null_values(&mut value);
|
||||
@@ -772,7 +772,7 @@ else {
|
||||
match req_result {
|
||||
Err(err) => {
|
||||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
sleep(Duration::from_millis(d.num_milliseconds() as u64));
|
||||
continue;
|
||||
}
|
||||
${delegate_finish}(false);
|
||||
@@ -782,10 +782,10 @@ else {
|
||||
if !res.status.is_success() {
|
||||
let mut json_err = String::new();
|
||||
res.read_to_string(&mut json_err).unwrap();
|
||||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||||
json::from_str(&json_err).ok(),
|
||||
json::from_str(&json_err).ok()) {
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
sleep(Duration::from_millis(d.num_milliseconds() as u64));
|
||||
continue;
|
||||
}
|
||||
${delegate_finish}(false);
|
||||
@@ -827,7 +827,7 @@ else {
|
||||
${delegate_finish}(false);
|
||||
return Err(Error::HttpError(err))
|
||||
}
|
||||
## Now the result contains the actual resource, if any ... it will be
|
||||
## Now the result contains the actual resource, if any ... it will be
|
||||
## decoded next
|
||||
Some(Ok(upload_result)) => {
|
||||
res = upload_result;
|
||||
@@ -884,4 +884,4 @@ if enable_resource_parsing \
|
||||
self.${api.terms.action}(${p.type.arg_name}, mime_type, "${p.protocol}")
|
||||
}
|
||||
% endfor
|
||||
</%def>
|
||||
</%def>
|
||||
|
||||
@@ -3,7 +3,8 @@ use std;
|
||||
use std::fmt::{self, Display};
|
||||
use std::str::FromStr;
|
||||
use std::error;
|
||||
use std::thread::sleep_ms;
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
use mime::{Mime, TopLevel, SubLevel, Attr, Value};
|
||||
use oauth2::{TokenType, Retry, self};
|
||||
@@ -41,7 +42,7 @@ pub trait RequestValue {}
|
||||
/// This might be a bug within the google API schema.
|
||||
pub trait UnusedType {}
|
||||
|
||||
/// Identifies types which are only used as part of other types, which
|
||||
/// Identifies types which are only used as part of other types, which
|
||||
/// usually are carrying the `Resource` trait.
|
||||
pub trait Part {}
|
||||
|
||||
@@ -76,7 +77,7 @@ pub struct ErrorResponse {
|
||||
pub struct ServerError {
|
||||
errors: Vec<ServerMessage>,
|
||||
code: u16,
|
||||
message: String,
|
||||
message: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
@@ -113,11 +114,11 @@ impl hyper::net::NetworkStream for DummyNetworkStream {
|
||||
Ok("127.0.0.1:1337".parse().unwrap())
|
||||
}
|
||||
|
||||
fn set_read_timeout(&self, _dur: Option<std::time::Duration>) -> io::Result<()> {
|
||||
fn set_read_timeout(&self, _dur: Option<Duration>) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_write_timeout(&self, _dur: Option<std::time::Duration>) -> io::Result<()> {
|
||||
fn set_write_timeout(&self, _dur: Option<Duration>) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -126,7 +127,7 @@ impl hyper::net::NetworkStream for DummyNetworkStream {
|
||||
/// A trait specifying functionality to help controlling any request performed by the API.
|
||||
/// The trait has a conservative default implementation.
|
||||
///
|
||||
/// It contains methods to deal with all common issues, as well with the ones related to
|
||||
/// It contains methods to deal with all common issues, as well with the ones related to
|
||||
/// uploading media
|
||||
pub trait Delegate {
|
||||
|
||||
@@ -134,12 +135,12 @@ 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 successful. That way, the delegate 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).
|
||||
///
|
||||
@@ -148,7 +149,7 @@ pub trait Delegate {
|
||||
Retry::Abort
|
||||
}
|
||||
|
||||
/// Called whenever there is the need for your applications API key after
|
||||
/// Called whenever there is the need for your applications API key after
|
||||
/// the official authenticator implementation didn't provide one, for some reason.
|
||||
/// If this method returns None as well, the underlying operation will fail
|
||||
fn api_key(&mut self) -> Option<String> {
|
||||
@@ -177,7 +178,7 @@ pub trait Delegate {
|
||||
}
|
||||
|
||||
/// Called after we have retrieved a new upload URL for a resumable upload to store it
|
||||
/// in case we fail or cancel. That way, we can attempt to resume the upload later,
|
||||
/// in case we fail or cancel. That way, we can attempt to resume the upload later,
|
||||
/// see `upload_url()`.
|
||||
/// It will also be called with None after a successful upload, which allows the delegate
|
||||
/// to forget the URL. That way, we will not attempt to resume an upload that has already
|
||||
@@ -189,7 +190,7 @@ pub trait Delegate {
|
||||
/// Called whenever a server response could not be decoded from json.
|
||||
/// It's for informational purposes only, the caller will return with an error
|
||||
/// accordingly.
|
||||
///
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
@@ -200,7 +201,7 @@ pub trait Delegate {
|
||||
}
|
||||
|
||||
/// Called whenever the http request returns with a non-success status code.
|
||||
/// This can involve authentication issues, or anything else that very much
|
||||
/// This can involve authentication issues, or anything else that very much
|
||||
/// 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.
|
||||
@@ -211,7 +212,7 @@ pub trait Delegate {
|
||||
Retry::Abort
|
||||
}
|
||||
|
||||
/// Called prior to sending the main request of the given method. It can be used to time
|
||||
/// Called prior to sending the main request of the given method. It can be used to time
|
||||
/// the call or to print progress information.
|
||||
/// It's also useful as you can be sure that a request will definitely be made.
|
||||
fn pre_request(&mut self) { }
|
||||
@@ -230,14 +231,14 @@ pub trait Delegate {
|
||||
fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool {
|
||||
let _ = chunk;
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Called before the API request method returns, in every case. It can be used to clean up
|
||||
/// internal state between calls to the API.
|
||||
/// This call always has a matching call to `begin(...)`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
///
|
||||
/// * `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) {
|
||||
@@ -302,9 +303,9 @@ impl Display for Error {
|
||||
Error::BadRequest(ref err) => {
|
||||
try!(writeln!(f, "Bad Requst ({}): {}", err.error.code, err.error.message));
|
||||
for err in err.error.errors.iter() {
|
||||
try!(writeln!(f, " {}: {}, {}{}",
|
||||
err.domain,
|
||||
err.message,
|
||||
try!(writeln!(f, " {}: {}, {}{}",
|
||||
err.domain,
|
||||
err.message,
|
||||
err.reason,
|
||||
match &err.location {
|
||||
&Some(ref loc) => format!("@{}", loc),
|
||||
@@ -315,13 +316,13 @@ impl Display for Error {
|
||||
},
|
||||
Error::MissingToken(ref err) =>
|
||||
writeln!(f, "Token retrieval failed with error: {}", err),
|
||||
Error::Cancelled =>
|
||||
Error::Cancelled =>
|
||||
writeln!(f, "Operation cancelled by delegate"),
|
||||
Error::FieldClash(field) =>
|
||||
writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field),
|
||||
Error::JsonDecodeError(ref json_str, ref err)
|
||||
Error::JsonDecodeError(ref json_str, ref err)
|
||||
=> writeln!(f, "{}: {}", err, json_str),
|
||||
Error::Failure(ref response) =>
|
||||
Error::Failure(ref response) =>
|
||||
writeln!(f, "Http status indicates failure: {:?}", response),
|
||||
}
|
||||
}
|
||||
@@ -416,8 +417,8 @@ impl<'a> MultiPartReader<'a> {
|
||||
|
||||
impl<'a> Read for MultiPartReader<'a> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
match (self.raw_parts.len(),
|
||||
self.current_part.is_none(),
|
||||
match (self.raw_parts.len(),
|
||||
self.current_part.is_none(),
|
||||
self.last_part_boundary.is_none()) {
|
||||
(_, _, false) => {
|
||||
let br = self.last_part_boundary.as_mut().unwrap().read(buf).unwrap_or(0);
|
||||
@@ -430,7 +431,7 @@ impl<'a> Read for MultiPartReader<'a> {
|
||||
(n, true, _) if n > 0 => {
|
||||
let (headers, reader) = self.raw_parts.remove(0);
|
||||
let mut c = Cursor::new(Vec::<u8>::new());
|
||||
(write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING,
|
||||
(write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING,
|
||||
headers, LINE_ENDING)).unwrap();
|
||||
c.seek(SeekFrom::Start(0)).unwrap();
|
||||
self.current_part = Some((c, reader));
|
||||
@@ -444,12 +445,12 @@ impl<'a> Read for MultiPartReader<'a> {
|
||||
let b = c.read(buf).unwrap_or(0);
|
||||
(b, reader.read(&mut buf[b..]))
|
||||
};
|
||||
|
||||
|
||||
match rr {
|
||||
Ok(bytes_read) => {
|
||||
if hb < buf.len() && bytes_read == 0 {
|
||||
if self.is_last_part() {
|
||||
// before clearing the last part, we will add the boundary that
|
||||
// before clearing the last part, we will add the boundary that
|
||||
// will be written last
|
||||
self.last_part_boundary = Some(Cursor::new(
|
||||
format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes()))
|
||||
@@ -496,7 +497,7 @@ impl<'a> Read for MultiPartReader<'a> {
|
||||
|
||||
/// The `X-Upload-Content-Type` header.
|
||||
///
|
||||
/// Generated via rustc --pretty expanded -Z unstable-options, and manually
|
||||
/// Generated via rustc --pretty expanded -Z unstable-options, and manually
|
||||
/// processed to be more readable.
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub struct XUploadContentType(pub Mime);
|
||||
@@ -655,7 +656,7 @@ impl<'a, A> ResumableUploadHelper<'a, A>
|
||||
Some(hh) if r.status == StatusCode::PermanentRedirect => hh,
|
||||
None|Some(_) => {
|
||||
if let Retry::After(d) = self.delegate.http_failure(&r, None, None) {
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
sleep(Duration::from_millis(d.num_milliseconds() as u64));
|
||||
continue;
|
||||
}
|
||||
return Err(Ok(r))
|
||||
@@ -665,7 +666,7 @@ impl<'a, A> ResumableUploadHelper<'a, A>
|
||||
}
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
sleep(Duration::from_millis(d.num_milliseconds() as u64));
|
||||
continue;
|
||||
}
|
||||
return Err(Err(err))
|
||||
@@ -723,10 +724,10 @@ impl<'a, A> ResumableUploadHelper<'a, A>
|
||||
if !res.status.is_success() {
|
||||
let mut json_err = String::new();
|
||||
res.read_to_string(&mut json_err).unwrap();
|
||||
if let Retry::After(d) = self.delegate.http_failure(&res,
|
||||
if let Retry::After(d) = self.delegate.http_failure(&res,
|
||||
json::from_str(&json_err).ok(),
|
||||
json::from_str(&json_err).ok()) {
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
sleep(Duration::from_millis(d.num_milliseconds() as u64));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -734,7 +735,7 @@ impl<'a, A> ResumableUploadHelper<'a, A>
|
||||
},
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep_ms(d.num_milliseconds() as u32);
|
||||
sleep(Duration::from_millis(d.num_milliseconds() as u64));
|
||||
continue;
|
||||
}
|
||||
return Some(Err(err))
|
||||
|
||||
Reference in New Issue
Block a user