Struct quic_rpc::client::RpcClient

source ·
pub struct RpcClient<S, C, SInner = S> { /* private fields */ }
Expand description

A client for a specific service

This is a wrapper around a ServiceConnection that serves as the entry point for the client DSL. S is the service type, C is the substream source.

Implementations§

source§

impl<S, C> RpcClient<S, C, S>
where S: Service, C: ServiceConnection<S>,

source

pub fn new(source: C) -> Self

Create a new rpc client for a specific Service given a compatible ServiceConnection.

This is where a generic typed connection is converted into a client for a specific service.

source§

impl<S, C, SInner> RpcClient<S, C, SInner>
where S: Service, C: ServiceConnection<S>, SInner: Service,

source

pub fn into_inner(self) -> C

Get the underlying connection

source

pub fn map<SNext>(self) -> RpcClient<S, C, SNext>
where SNext: Service, SNext::Req: Into<SInner::Req> + TryFrom<SInner::Req>, SNext::Res: Into<SInner::Res> + TryFrom<SInner::Res>,

Map this channel’s service into an inner service.

This method is available if the required bounds are upheld: SNext::Req: IntoSInner::Req + TryFromSInner::Req, SNext::Res: IntoSInner::Res + TryFromSInner::Res,

Where SNext is the new service to map to and SInner is the current inner service.

This method can be chained infintely.

source§

impl<S, C, SInner> RpcClient<S, C, SInner>
where S: Service, C: ServiceConnection<S>, SInner: Service,

source

pub async fn bidi<M>( &self, msg: M, ) -> Result<(UpdateSink<S, C, M::Update, SInner>, BoxStreamSync<'static, Result<M::Response, ItemError<C>>>), Error<C>>
where M: BidiStreamingMsg<SInner>,

Bidi call to the server, request opens a stream, response is a stream

source§

impl<S, C, SInner> RpcClient<S, C, SInner>
where S: Service, C: ServiceConnection<S>, SInner: Service,

source

pub async fn client_streaming<M>( &self, msg: M, ) -> Result<(UpdateSink<S, C, M::Update, SInner>, Boxed<Result<M::Response, ItemError<C>>>), Error<C>>
where M: ClientStreamingMsg<SInner>,

Call to the server that allows the client to stream, single response

source§

impl<S, C, SInner> RpcClient<S, C, SInner>
where S: Service, C: ServiceConnection<S>, SInner: Service,

source

pub async fn rpc<M>(&self, msg: M) -> Result<M::Response, Error<C>>
where M: RpcMsg<SInner>,

RPC call to the server, single request, single response

source§

impl<S, C, SInner> RpcClient<S, C, SInner>
where S: Service, C: ServiceConnection<S>, SInner: Service,

source

pub async fn server_streaming<M>( &self, msg: M, ) -> Result<BoxStreamSync<'static, Result<M::Response, ItemError<C>>>, Error<C>>
where M: ServerStreamingMsg<SInner>,

Bidi call to the server, request opens a stream, response is a stream

source§

impl<S, C, SInner> RpcClient<S, C, SInner>
where S: Service, C: ServiceConnection<S>, SInner: Service,

source

pub async fn try_server_streaming<M>( &self, msg: M, ) -> Result<BoxStreamSync<'static, Result<M::Item, ItemError<C, M::ItemError>>>, Error<C, M::CreateError>>
where M: TryServerStreamingMsg<SInner>, Result<M::Item, M::ItemError>: Into<SInner::Res> + TryFrom<SInner::Res>, Result<StreamCreated, M::CreateError>: Into<SInner::Res> + TryFrom<SInner::Res>,

Bidi call to the server, request opens a stream, response is a stream

Trait Implementations§

source§

impl<S, C, SInner> AsRef<C> for RpcClient<S, C, SInner>
where S: Service, C: ServiceConnection<S>, SInner: Service,

source§

fn as_ref(&self) -> &C

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<S, C: Clone, SInner> Clone for RpcClient<S, C, SInner>

source§

fn clone(&self) -> Self

Returns a copy 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<S: Debug, C: Debug, SInner: Debug> Debug for RpcClient<S, C, SInner>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, C, SInner> Freeze for RpcClient<S, C, SInner>
where C: Freeze,

§

impl<S, C, SInner = S> !RefUnwindSafe for RpcClient<S, C, SInner>

§

impl<S, C, SInner> Send for RpcClient<S, C, SInner>
where C: Send,

§

impl<S, C, SInner> Sync for RpcClient<S, C, SInner>
where C: Sync,

§

impl<S, C, SInner> Unpin for RpcClient<S, C, SInner>
where C: Unpin,

§

impl<S, C, SInner = S> !UnwindSafe for RpcClient<S, C, SInner>

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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