pub struct RpcClient<S, C = BoxedServiceConnection<S>, SC = 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.
Type parameters:
S
is the service type that determines what interactions this client supports.
SC
is the service type that is compatible with the connection.
C
is the substream source.
Implementations§
Source§impl<S, C> RpcClient<S, C, S>where
S: Service,
C: ServiceConnection<S>,
impl<S, C> RpcClient<S, C, S>where
S: Service,
C: ServiceConnection<S>,
Sourcepub fn new(source: C) -> Self
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.
When creating a new client, the outer service type S
and the inner
service type SC
that is compatible with the underlying connection will
be identical.
You can get a client for a nested service by calling map.
Source§impl<S, C, SC> RpcClient<S, C, SC>
impl<S, C, SC> RpcClient<S, C, SC>
Sourcepub fn into_inner(self) -> C
pub fn into_inner(self) -> C
Get the underlying connection
Sourcepub fn map<SNext>(self) -> RpcClient<SNext, C, SC>
pub fn map<SNext>(self) -> RpcClient<SNext, C, SC>
Map this channel’s service into an inner service.
This method is available if the required bounds are upheld: SNext::Req: Into<S::Req> + TryFrom<S::Req>, SNext::Res: Into<S::Res> + TryFrom<S::Res>,
Where SNext is the new service to map to and S is the current inner service.
This method can be chained infintely.
Source§impl<S, C, SC> RpcClient<S, C, SC>
impl<S, C, SC> RpcClient<S, C, SC>
Sourcepub async fn bidi<M>(
&self,
msg: M,
) -> Result<(UpdateSink<SC, C, M::Update, S>, BoxStreamSync<'static, Result<M::Response, ItemError<C>>>), Error<C>>where
M: BidiStreamingMsg<S>,
pub async fn bidi<M>(
&self,
msg: M,
) -> Result<(UpdateSink<SC, C, M::Update, S>, BoxStreamSync<'static, Result<M::Response, ItemError<C>>>), Error<C>>where
M: BidiStreamingMsg<S>,
Bidi call to the server, request opens a stream, response is a stream
Source§impl<S, C, SC> RpcClient<S, C, SC>
impl<S, C, SC> RpcClient<S, C, SC>
Sourcepub async fn client_streaming<M>(
&self,
msg: M,
) -> Result<(UpdateSink<SC, C, M::Update, S>, Boxed<Result<M::Response, ItemError<C>>>), Error<C>>where
M: ClientStreamingMsg<S>,
pub async fn client_streaming<M>(
&self,
msg: M,
) -> Result<(UpdateSink<SC, C, M::Update, S>, Boxed<Result<M::Response, ItemError<C>>>), Error<C>>where
M: ClientStreamingMsg<S>,
Call to the server that allows the client to stream, single response
Source§impl<S, C, SC> RpcClient<S, C, SC>
impl<S, C, SC> RpcClient<S, C, SC>
Sourcepub async fn server_streaming<M>(
&self,
msg: M,
) -> Result<BoxStreamSync<'static, Result<M::Response, ItemError<C>>>, Error<C>>where
M: ServerStreamingMsg<S>,
pub async fn server_streaming<M>(
&self,
msg: M,
) -> Result<BoxStreamSync<'static, Result<M::Response, ItemError<C>>>, Error<C>>where
M: ServerStreamingMsg<S>,
Bidi call to the server, request opens a stream, response is a stream
Source§impl<S, C, SC> RpcClient<S, C, SC>
impl<S, C, SC> RpcClient<S, C, SC>
Sourcepub 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<S>,
Result<M::Item, M::ItemError>: Into<S::Res> + TryFrom<S::Res>,
Result<StreamCreated, M::CreateError>: Into<S::Res> + TryFrom<S::Res>,
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<S>,
Result<M::Item, M::ItemError>: Into<S::Res> + TryFrom<S::Res>,
Result<StreamCreated, M::CreateError>: Into<S::Res> + TryFrom<S::Res>,
Bidi call to the server, request opens a stream, response is a stream
Trait Implementations§
Auto Trait Implementations§
impl<S, C, SC> Freeze for RpcClient<S, C, SC>where
C: Freeze,
impl<S, C = Connection<<S as Service>::Res, <S as Service>::Req>, SC = S> !RefUnwindSafe for RpcClient<S, C, SC>
impl<S, C, SC> Send for RpcClient<S, C, SC>where
C: Send,
impl<S, C, SC> Sync for RpcClient<S, C, SC>where
C: Sync,
impl<S, C, SC> Unpin for RpcClient<S, C, SC>where
C: Unpin,
impl<S, C = Connection<<S as Service>::Res, <S as Service>::Req>, SC = S> !UnwindSafe for RpcClient<S, C, SC>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)