Skip to main content

ClientPool

Struct ClientPool 

Source
pub struct ClientPool<RM>
where RM: ResourceManager,
{ /* private fields */ }
Available on crate features http and http-client-pool only.
Expand description

An optioned pool of different HTTP connections lazily constructed from different URIs.

Currently supports only one domain with multiple connections.

Implementations§

Source§

impl<AUX, HB, RM, SW> ClientPool<RM>
where HB: LeaseMut<Http2Buffer>, RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter,

Source

pub async fn close_all(&self)

Closes all active connections

Source

pub async fn lock<'this>( &'this self, uri: &UriRef<'_>, ) -> Result<SimplePoolGetElem<AsyncMutexGuard<'this, SimplePoolResource<RM::Resource>>>>
where AUX: 'this, HB: 'this, SW: 'this,

Returns a guard that contains the internal elements.

Trait Implementations§

Source§

impl<RM> Clone for ClientPool<RM>
where RM: ResourceManager + Clone,

Source§

fn clone(&self) -> ClientPool<RM>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<RM> Debug for ClientPool<RM>
where RM: ResourceManager + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<AUX, HB, RM, SW> HttpClient for &ClientPool<RM>
where HB: LeaseMut<Http2Buffer>, RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter,

Source§

type ReqId = ClientStream<HB, SW>

If applicable, can be used by clients to poll specific requests returned by HttpClient::send_req.
Source§

async fn recv_res( &self, rrb: ReqResBuffer, req_id: Self::ReqId, ) -> Result<Response<ReqResBuffer>>

Receives a response
Source§

async fn send_req<RRD>( &self, enc_buffer: &mut Vector<u8>, rb: ReqBuilder<RRD>, ) -> Result<Self::ReqId>
where RRD: ReqResData, RRD::Body: Lease<[u8]>,

Sends a request
Source§

fn send_req_recv_res<RRD>( &self, rrb: ReqResBuffer, rb: ReqBuilder<RRD>, ) -> impl Future<Output = Result<Response<ReqResBuffer>>>
where RRD: ReqResData, RRD::Body: Lease<[u8]>,

Sends a request a ReqResData and receives a response using ReqResBuffer.
Source§

impl<AUX, HB, RM, SW> HttpClient for ClientPool<RM>
where HB: LeaseMut<Http2Buffer>, RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter,

Source§

type ReqId = ClientStream<HB, SW>

If applicable, can be used by clients to poll specific requests returned by HttpClient::send_req.
Source§

async fn recv_res( &self, rrb: ReqResBuffer, req_id: Self::ReqId, ) -> Result<Response<ReqResBuffer>>

Receives a response
Source§

async fn send_req<RRD>( &self, enc_buffer: &mut Vector<u8>, rb: ReqBuilder<RRD>, ) -> Result<Self::ReqId>
where RRD: ReqResData, RRD::Body: Lease<[u8]>,

Sends a request
Source§

fn send_req_recv_res<RRD>( &self, rrb: ReqResBuffer, rb: ReqBuilder<RRD>, ) -> impl Future<Output = Result<Response<ReqResBuffer>>>
where RRD: ReqResData, RRD::Body: Lease<[u8]>,

Sends a request a ReqResData and receives a response using ReqResBuffer.
Source§

impl<AUX, HB, RM, SW, TP> ReceivingTransport<TP> for &ClientPool<RM>
where HB: LeaseMut<Http2Buffer>, RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter, TP: LeaseMut<HttpParams>,

Available on crate features http2 and client-api-framework only.
Source§

async fn recv<A, DRSR>( &mut self, pkgs_aux: &mut PkgsAux<A, DRSR, TP>, req_id: Self::ReqId, ) -> Result<(), A::Error>
where A: Api,

Retrieves data from the server filling the internal buffer and returning the amount of bytes written.
Source§

fn recv_decode_contained<'de, A, DRSR, P>( &mut self, pkgs_aux: &'de mut PkgsAux<A, DRSR, TP>, req_id: Self::ReqId, ) -> impl Future<Output = Result<P::ExternalResponseContent<'de>, A::Error>>
where A: Api, P: Package<A, DRSR, Self::Inner, TP>,

Internally calls Self::recv and then tries to decode the defined response specified in Package::ExternalResponseContent.
Source§

impl<AUX, HB, RM, SW, TP> ReceivingTransport<TP> for ClientPool<RM>
where HB: LeaseMut<Http2Buffer>, RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter, TP: LeaseMut<HttpParams>,

Available on crate features http2 and client-api-framework only.
Source§

async fn recv<A, DRSR>( &mut self, pkgs_aux: &mut PkgsAux<A, DRSR, TP>, req_id: Self::ReqId, ) -> Result<(), A::Error>
where A: Api,

Retrieves data from the server filling the internal buffer and returning the amount of bytes written.
Source§

fn recv_decode_contained<'de, A, DRSR, P>( &mut self, pkgs_aux: &'de mut PkgsAux<A, DRSR, TP>, req_id: Self::ReqId, ) -> impl Future<Output = Result<P::ExternalResponseContent<'de>, A::Error>>
where A: Api, P: Package<A, DRSR, Self::Inner, TP>,

Internally calls Self::recv and then tries to decode the defined response specified in Package::ExternalResponseContent.
Source§

impl<AUX, HB, RM, SW, TP> SendingTransport<TP> for &ClientPool<RM>
where HB: LeaseMut<Http2Buffer>, RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter, TP: LeaseMut<HttpParams>,

Available on crate features http2 and client-api-framework only.
Source§

async fn send_bytes<A, DRSR>( &mut self, bytes: &[u8], pkgs_aux: &mut PkgsAux<A, DRSR, TP>, ) -> Result<Self::ReqId, A::Error>
where A: Api,

Sends a sequence of bytes without trying to retrieve any counterpart data.
Source§

async fn send_pkg<A, DRSR, P>( &mut self, pkg: &mut P, pkgs_aux: &mut PkgsAux<A, DRSR, TP>, ) -> Result<Self::ReqId, A::Error>
where A: Api, P: Package<A, DRSR, Self::Inner, TP>,

Sends a package without trying to retrieve any counterpart data.
Source§

impl<AUX, HB, RM, SW, TP> SendingTransport<TP> for ClientPool<RM>
where HB: LeaseMut<Http2Buffer>, RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter, TP: LeaseMut<HttpParams>,

Available on crate features http2 and client-api-framework only.
Source§

async fn send_bytes<A, DRSR>( &mut self, bytes: &[u8], pkgs_aux: &mut PkgsAux<A, DRSR, TP>, ) -> Result<Self::ReqId, A::Error>
where A: Api,

Sends a sequence of bytes without trying to retrieve any counterpart data.
Source§

async fn send_pkg<A, DRSR, P>( &mut self, pkg: &mut P, pkgs_aux: &mut PkgsAux<A, DRSR, TP>, ) -> Result<Self::ReqId, A::Error>
where A: Api, P: Package<A, DRSR, Self::Inner, TP>,

Sends a package without trying to retrieve any counterpart data.
Source§

impl<AUX, HB, RM, SW, TP> Transport<TP> for &ClientPool<RM>
where HB: LeaseMut<Http2Buffer>, RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter,

Available on crate features http2 and client-api-framework only.
Source§

const GROUP: TransportGroup = TransportGroup::HTTP

Source§

type Inner = Http2<HB, SW, true>

The inner implementation.
Source§

type ReqId = ClientStream<HB, SW>

If applicable, can be used by clients to poll specific sent requests.
Source§

fn ty(&self) -> TransportGroup

Instance counterpart of Self::GROUP.
Source§

impl<AUX, HB, RM, SW, TP> Transport<TP> for ClientPool<RM>
where RM: ResourceManager<CreateAux = str, Error = Error, RecycleAux = str, Resource = ClientPoolResource<AUX, Http2<HB, SW, true>>>, SW: StreamWriter,

Available on crate features http2 and client-api-framework only.
Source§

const GROUP: TransportGroup = TransportGroup::HTTP

Source§

type Inner = Http2<HB, SW, true>

The inner implementation.
Source§

type ReqId = ClientStream<HB, SW>

If applicable, can be used by clients to poll specific sent requests.
Source§

fn ty(&self) -> TransportGroup

Instance counterpart of Self::GROUP.

Auto Trait Implementations§

§

impl<RM> Freeze for ClientPool<RM>

§

impl<RM> !RefUnwindSafe for ClientPool<RM>

§

impl<RM> Send for ClientPool<RM>
where RM: Sync + Send, <RM as ResourceManager>::Resource: Send,

§

impl<RM> Sync for ClientPool<RM>
where RM: Sync + Send, <RM as ResourceManager>::Resource: Send,

§

impl<RM> Unpin for ClientPool<RM>

§

impl<RM> !UnwindSafe for ClientPool<RM>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, TP> SendingReceivingTransport<TP> for T

Source§

fn send_bytes_recv<A, DRSR>( &mut self, bytes: &[u8], pkgs_aux: &mut PkgsAux<A, DRSR, TP>, ) -> impl Future<Output = Result<(), A::Error>>
where A: Api,

Available on crate feature client-api-framework only.
Sends a sequence of bytes and then awaits its counterpart data response. Read more
Source§

fn send_pkg_recv<A, DRSR, P>( &mut self, pkg: &mut P, pkgs_aux: &mut PkgsAux<A, DRSR, TP>, ) -> impl Future<Output = Result<(), A::Error>>
where A: Api, P: Package<A, DRSR, Self::Inner, TP>,

Available on crate feature client-api-framework only.
Sends a package and then awaits its counterpart data response. Read more
Source§

fn send_pkg_recv_decode_batch<'pkgs, 'pkgs_aux, A, DRSR, P>( &mut self, buffer: &mut Vector<P::ExternalResponseContent<'pkgs_aux>>, pkgs: &'pkgs mut [P], pkgs_aux: &'pkgs_aux mut PkgsAux<A, DRSR, TP>, ) -> impl Future<Output = Result<(), A::Error>>
where A: Api, P: Package<A, DRSR, Self::Inner, TP>, BatchElems<'pkgs, A, DRSR, P, Self::Inner, TP>: Encode<De<DRSR>>,

Available on crate feature client-api-framework only.
Convenient method similar to Self::send_pkg_recv_decode_contained but used for batch requests. Read more
Source§

fn send_pkg_recv_decode_contained<'de, A, DRSR, P>( &mut self, pkg: &mut P, pkgs_aux: &'de mut PkgsAux<A, DRSR, TP>, ) -> impl Future<Output = Result<P::ExternalResponseContent<'de>, A::Error>>
where A: Api, P: Package<A, DRSR, Self::Inner, TP>,

Available on crate feature client-api-framework only.
Internally calls Self::send_pkg_recv and then tries to decode the defined response specified in Package::ExternalResponseContent.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more