Trait google_doubleclicksearch2::Delegate[][src]

pub trait Delegate {
    fn begin(&mut self, MethodInfo) { ... }
fn http_error(&mut self, &Error) -> Retry { ... }
fn api_key(&mut self) -> Option<String> { ... }
fn token(&mut self, err: &Error) -> Option<Token> { ... }
fn upload_url(&mut self) -> Option<String> { ... }
fn store_upload_url(&mut self, url: Option<&str>) { ... }
fn response_json_decode_error(
        &mut self,
        json_encoded_value: &str,
        json_decode_error: &Error
    ) { ... }
fn http_failure(
        &mut self,
        _: &Response,
        Option<JsonServerError>,
        _: Option<ServerError>
    ) -> Retry { ... }
fn pre_request(&mut self) { ... }
fn chunk_size(&mut self) -> u64 { ... }
fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool { ... }
fn finished(&mut self, is_success: bool) { ... } }

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 uploading media

Provided Methods

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.

Called whenever there is an HttpError, usually if there are network problems.

If you choose to retry after a duration, the duration should be chosen using the exponential backoff algorithm.

Return retry information.

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

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

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.

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.

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.
  • json_decode_error - The decoder error

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.

If you choose to retry after a duration, the duration should be chosen using the exponential backoff algorithm.

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.

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.

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()

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.

Implementors