Struct http_typed::Client
source · pub struct Client<RequestGroup = All> { /* private fields */ }Expand description
A client to delegate to the send function that provides the ability to optionally specify:
- a base url to be used for all requests
- a request group to constrain the request types accepted by this type
Implementations§
source§impl<RequestGroup> Client<RequestGroup>
impl<RequestGroup> Client<RequestGroup>
pub fn new(base_url: String) -> Self
sourcepub async fn send_to<Req>(
base_url: &str,
request: Req
) -> Result<Req::Response, Error>where
Req: Request + Serialize + InRequestGroup<RequestGroup>,
Req::Response: for<'a> Deserialize<'a>,
pub async fn send_to<Req>( base_url: &str, request: Req ) -> Result<Req::Response, Error>where Req: Request + Serialize + InRequestGroup<RequestGroup>, Req::Response: for<'a> Deserialize<'a>,
Send the provided request to the host at the specified base url, using
the request metadata specified by the Request implementation. This
method upgrades from the send function by enabling you to constrain
the request group with the type system.
sourcepub async fn send<Req>(&self, request: Req) -> Result<Req::Response, Error>where
Req: Request + Serialize + InRequestGroup<RequestGroup>,
Req::Response: for<'a> Deserialize<'a>,
pub async fn send<Req>(&self, request: Req) -> Result<Req::Response, Error>where Req: Request + Serialize + InRequestGroup<RequestGroup>, Req::Response: for<'a> Deserialize<'a>,
Send the provided request to the host at the specified base url, using
the request metadata specified by the Request implementation. This
method upgrades from the send_to method by allowing you specify the
base url at the time of instantiation rather than passing it to every
send call.
Trait Implementations§
Auto Trait Implementations§
impl<RequestGroup> RefUnwindSafe for Client<RequestGroup>where RequestGroup: RefUnwindSafe,
impl<RequestGroup> Send for Client<RequestGroup>where RequestGroup: Send,
impl<RequestGroup> Sync for Client<RequestGroup>where RequestGroup: Sync,
impl<RequestGroup> Unpin for Client<RequestGroup>where RequestGroup: Unpin,
impl<RequestGroup> UnwindSafe for Client<RequestGroup>where RequestGroup: UnwindSafe,
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