pub struct DefaultDelegate;
Expand description
A delegate with a conservative default implementation, which is used if no other delegate is set.
Trait Implementations§
source§impl Default for DefaultDelegate
impl Default for DefaultDelegate
source§fn default() -> DefaultDelegate
fn default() -> DefaultDelegate
Returns the “default value” for a type. Read more
source§impl Delegate for DefaultDelegate
impl Delegate for DefaultDelegate
source§fn begin(&mut self, _info: MethodInfo)
fn begin(&mut self, _info: MethodInfo)
Called at the beginning of any API request. The delegate should store the method
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
between various API calls.source§fn http_error(&mut self, _err: &Error) -> Retry
fn http_error(&mut self, _err: &Error) -> Retry
source§fn api_key(&mut self) -> Option<String>
fn api_key(&mut self) -> Option<String>
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
source§fn token(
&mut self,
e: Box<dyn Error + Send + Sync>,
) -> Result<Option<String>, Box<dyn Error + Send + Sync>>
fn token( &mut self, e: Box<dyn Error + Send + Sync>, ) -> Result<Option<String>, Box<dyn Error + Send + Sync>>
Called whenever the Authenticator didn’t yield a token. The delegate
may attempt to provide one, or just take it as a general information about the
impending failure.
The given Error provides information about why the token couldn’t be acquired in the
first place
source§fn upload_url(&mut self) -> Option<String>
fn upload_url(&mut self) -> Option<String>
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/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.source§fn store_upload_url(&mut self, url: Option<&str>)
fn store_upload_url(&mut self, url: Option<&str>)
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,
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
finished.source§fn response_json_decode_error(
&mut self,
json_encoded_value: &str,
json_decode_error: &Error,
)
fn response_json_decode_error( &mut self, json_encoded_value: &str, json_decode_error: &Error, )
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. Read more
source§fn http_failure(&mut self, _: &Response, _err: Option<&Value>) -> Retry
fn http_failure(&mut self, _: &Response, _err: Option<&Value>) -> Retry
Called whenever the http request returns with a non-success status code.
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. Read more
source§fn pre_request(&mut self)
fn pre_request(&mut self)
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.
source§fn chunk_size(&mut self) -> u64
fn chunk_size(&mut self) -> u64
Return the size of each chunk of a resumable upload.
Must be a power of two, with 1<<18 being the smallest allowed chunk size.
Will be called once before starting any resumable upload.
source§fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool
fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool
Called before the given chunk is uploaded to the server.
If true is returned, the upload will be interrupted.
However, it may be resumable if you stored the upload URL in a previous call
to
store_upload_url()
Auto Trait Implementations§
impl Freeze for DefaultDelegate
impl RefUnwindSafe for DefaultDelegate
impl Send for DefaultDelegate
impl Sync for DefaultDelegate
impl Unpin for DefaultDelegate
impl UnwindSafe for DefaultDelegate
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more