pub struct RestClient<'a, Strategy, Parser> {
pub http_client: Client,
pub base_url: Cow<'a, str>,
pub strategy: Strategy,
pub parser: Parser,
}Expand description
Configurable REST client capable of executing signed RestRequests. Use this when
integrating APIs that require Http in order to interact with resources. Each API will require
a specific combination of Signer, Mac,
signature Encoder, and
HttpParser.
Fields§
§http_client: ClientHTTP reqwest::Client for executing signed reqwest::Requests.
base_url: Cow<'a, str>Base Url of the API being interacted with.
strategy: StrategyRestRequest build strategy for the API being interacted with that implements
BuildStrategy.
An authenticated RestClient will utilise API specific
Signer logic, a hashable Mac, and a
signature Encoder. Where as a non authorised
RestRequest may add any mandatory reqwest headers that are required.
parser: ParserHttpParser that deserialises RestRequest::Responses, and upon failure parses
API errors returned from the server.
Implementations§
Source§impl<Strategy, Parser> RestClient<'_, Strategy, Parser>where
Strategy: BuildStrategy,
Parser: HttpParser,
impl<Strategy, Parser> RestClient<'_, Strategy, Parser>where
Strategy: BuildStrategy,
Parser: HttpParser,
Sourcepub async fn execute<Request>(
&self,
request: Request,
) -> Result<(Request::Response, Metric), Parser::OutputError>where
Request: RestRequest,
pub async fn execute<Request>(
&self,
request: Request,
) -> Result<(Request::Response, Metric), Parser::OutputError>where
Request: RestRequest,
Execute the provided RestRequest.
Sourcepub fn build<Request>(&self, request: Request) -> Result<Request, SocketError>where
Request: RestRequest,
pub fn build<Request>(&self, request: Request) -> Result<Request, SocketError>where
Request: RestRequest,
Use the provided RestRequest to construct a signed Http reqwest::Request.
Sourcepub async fn measured_execution<Request>(
&self,
request: Request,
) -> Result<(StatusCode, Bytes, Metric), SocketError>where
Request: RestRequest,
pub async fn measured_execution<Request>(
&self,
request: Request,
) -> Result<(StatusCode, Bytes, Metric), SocketError>where
Request: RestRequest,
Execute the built reqwest::Request using the reqwest::Client.
Measures and returns the Http request round trip duration.
Trait Implementations§
Auto Trait Implementations§
impl<'a, Strategy, Parser> Freeze for RestClient<'a, Strategy, Parser>
impl<'a, Strategy, Parser> !RefUnwindSafe for RestClient<'a, Strategy, Parser>
impl<'a, Strategy, Parser> Send for RestClient<'a, Strategy, Parser>
impl<'a, Strategy, Parser> Sync for RestClient<'a, Strategy, Parser>
impl<'a, Strategy, Parser> Unpin for RestClient<'a, Strategy, Parser>
impl<'a, Strategy, Parser> !UnwindSafe for RestClient<'a, Strategy, Parser>
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
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>
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>
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