Function screeps_api::connecting::interpret [] [src]

pub fn interpret<T, R>(
    token_storage: T,
    used_token: Option<Token>,
    url: Url,
    response: FutureResponse
) -> FutureResponse<R> where
    T: TokenStorage,
    R: EndpointType

Interpret a hyper result as the result from a specific endpoint.

The returned future will:

  • Wait for the hyper request to finish
  • Send any auth token found in headers back to token storage
  • Wait for hyper request body, collecting it into a single chunk
  • Parse JSON body as the given EndpointType, and return result/error.

All errors returned will have the given Url contained as part of the context.

Parameters

  • token_storage: token storage to store any tokens that were refreshed.
  • used_token: token that was used when sending this request, if any. if the server doesn't return a new token, and this is Some, the inner token will be returned to the token storage.
  • url: url that is being queried, used only for error and warning messages.
  • response: actual hyper response that we're interpreting