pub struct Client {
pub http: Client,
pub base: String,
}
Expand description
A client based on the reqwest::Client which can be used for executing Endpoints. A backing instance of a reqwest::Client is used to increase performance and to save certain characteristics across sessions. A base URL is required and is used to qualify the full path of any Endpoints which are executed by this client.
§Example
use rustify::clients::reqwest::Client;
use rustify::Endpoint;
use rustify_derive::Endpoint;
use serde::Serialize;
#[derive(Debug, Endpoint, Serialize)]
#[endpoint(path = "my/endpoint")]
struct MyEndpoint {}
let client = Client::default("http://myapi.com");
let endpoint = MyEndpoint {};
let result = endpoint.exec(&client).await;
Fields§
§http: Client
§base: String
Implementations§
Trait Implementations§
source§impl Client for Client
impl Client for Client
source§fn base(&self) -> &str
fn base(&self) -> &str
Returns the base URL the client is configured with. This is used for
creating the fully qualified URLs used when executing
Endpoints.
source§fn send<'life0, 'async_trait>(
&'life0 self,
req: Request<Vec<u8>>,
) -> Pin<Box<dyn Future<Output = Result<Response<Vec<u8>>, ClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
req: Request<Vec<u8>>,
) -> Pin<Box<dyn Future<Output = Result<Response<Vec<u8>>, ClientError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends the given Request and returns a Response. Implementations
should consolidate all errors into the ClientError type.
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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