Struct distant_net::Client
source · [−]pub struct Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static, { /* private fields */ }
Expand description
Represents a client that can be used to send requests & receive responses from a server
Implementations
sourceimpl<T, U> Client<T, U> where
T: Send + Sync + Serialize,
U: Send + Sync + DeserializeOwned,
impl<T, U> Client<T, U> where
T: Send + Sync + Serialize,
U: Send + Sync + DeserializeOwned,
sourcepub fn new<R, W>(writer: W, reader: R) -> Result<Self> where
R: TypedAsyncRead<Response<U>> + Send + 'static,
W: TypedAsyncWrite<Request<T>> + Send + 'static,
pub fn new<R, W>(writer: W, reader: R) -> Result<Self> where
R: TypedAsyncRead<Response<U>> + Send + 'static,
W: TypedAsyncWrite<Request<T>> + Send + 'static,
Initializes a client using the provided reader and writer
sourcepub fn from_framed_transport<TR, C>(
transport: FramedTransport<TR, C>
) -> Result<Self> where
TR: RawTransport + IntoSplit + 'static,
<TR as IntoSplit>::Read: RawTransportRead,
<TR as IntoSplit>::Write: RawTransportWrite,
C: Codec + Send + 'static,
pub fn from_framed_transport<TR, C>(
transport: FramedTransport<TR, C>
) -> Result<Self> where
TR: RawTransport + IntoSplit + 'static,
<TR as IntoSplit>::Read: RawTransportRead,
<TR as IntoSplit>::Write: RawTransportWrite,
C: Codec + Send + 'static,
Initializes a client using the provided framed transport
sourcepub fn into_channel(self) -> Channel<T, U>
pub fn into_channel(self) -> Channel<T, U>
Convert into underlying channel
sourcepub fn clone_channel(&self) -> Channel<T, U>
pub fn clone_channel(&self) -> Channel<T, U>
Clones the underlying channel for requests and returns the cloned instance
sourcepub async fn wait(self) -> Result<(), JoinError>
pub async fn wait(self) -> Result<(), JoinError>
Waits for the client to terminate, which results when the receiving end of the network connection is closed (or the client is shutdown)
sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if client’s underlying event processing has finished/terminated
Methods from Deref<Target = Channel<T, U>>
sourcepub async fn mail(
&mut self,
req: impl Into<Request<T>>
) -> Result<Mailbox<Response<U>>>
pub async fn mail(
&mut self,
req: impl Into<Request<T>>
) -> Result<Mailbox<Response<U>>>
Sends a request and returns a mailbox that can receive one or more responses, failing if unable to send a request or if the session’s receiving line to the remote server has already been severed
sourcepub async fn mail_timeout(
&mut self,
req: impl Into<Request<T>>,
duration: impl Into<Option<Duration>>
) -> Result<Mailbox<Response<U>>>
pub async fn mail_timeout(
&mut self,
req: impl Into<Request<T>>,
duration: impl Into<Option<Duration>>
) -> Result<Mailbox<Response<U>>>
Sends a request and returns a mailbox, timing out after duration has passed
sourcepub async fn send(&mut self, req: impl Into<Request<T>>) -> Result<Response<U>>
pub async fn send(&mut self, req: impl Into<Request<T>>) -> Result<Response<U>>
Sends a request and waits for a response, failing if unable to send a request or if the session’s receiving line to the remote server has already been severed
sourcepub async fn send_timeout(
&mut self,
req: impl Into<Request<T>>,
duration: impl Into<Option<Duration>>
) -> Result<Response<U>>
pub async fn send_timeout(
&mut self,
req: impl Into<Request<T>>,
duration: impl Into<Option<Duration>>
) -> Result<Response<U>>
Sends a request and waits for a response, timing out after duration has passed
Trait Implementations
sourceimpl<T, U> Deref for Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
impl<T, U> Deref for Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
sourceimpl<T, U> DerefMut for Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
impl<T, U> DerefMut for Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
sourceimpl<T, U> From<Client<T, U>> for Channel<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
impl<T, U> From<Client<T, U>> for Channel<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
sourceimpl<T, U> TcpClientExt<T, U> for Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
impl<T, U> TcpClientExt<T, U> for Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
sourcefn connect<'async_trait, C>(
addr: SocketAddr,
codec: C
) -> Pin<Box<dyn Future<Output = Result<Client<T, U>>> + Send + 'async_trait>> where
C: Codec + Send + 'static,
C: 'async_trait,
Self: 'async_trait,
fn connect<'async_trait, C>(
addr: SocketAddr,
codec: C
) -> Pin<Box<dyn Future<Output = Result<Client<T, U>>> + Send + 'async_trait>> where
C: Codec + Send + 'static,
C: 'async_trait,
Self: 'async_trait,
Connect to a remote TCP server using the provided information
sourcefn connect_timeout<'async_trait, C>(
addr: SocketAddr,
codec: C,
duration: Duration
) -> Pin<Box<dyn Future<Output = Result<Client<T, U>>> + Send + 'async_trait>> where
C: Codec + Send + 'static,
C: 'async_trait,
Self: Send + 'async_trait,
fn connect_timeout<'async_trait, C>(
addr: SocketAddr,
codec: C,
duration: Duration
) -> Pin<Box<dyn Future<Output = Result<Client<T, U>>> + Send + 'async_trait>> where
C: Codec + Send + 'static,
C: 'async_trait,
Self: Send + 'async_trait,
Connect to a remote TCP server, timing out after duration has passed
sourceimpl<T, U> UnixSocketClientExt<T, U> for Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
impl<T, U> UnixSocketClientExt<T, U> for Client<T, U> where
T: Send + Sync + Serialize + 'static,
U: Send + Sync + DeserializeOwned + 'static,
sourcefn connect<'async_trait, P, C>(
path: P,
codec: C
) -> Pin<Box<dyn Future<Output = Result<Client<T, U>>> + Send + 'async_trait>> where
P: AsRef<Path> + Send,
C: Codec + Send + 'static,
P: 'async_trait,
C: 'async_trait,
fn connect<'async_trait, P, C>(
path: P,
codec: C
) -> Pin<Box<dyn Future<Output = Result<Client<T, U>>> + Send + 'async_trait>> where
P: AsRef<Path> + Send,
C: Codec + Send + 'static,
P: 'async_trait,
C: 'async_trait,
Connect to a proxy unix socket
sourcefn connect_timeout<'async_trait, P, C>(
path: P,
codec: C,
duration: Duration
) -> Pin<Box<dyn Future<Output = Result<Client<T, U>>> + Send + 'async_trait>> where
P: AsRef<Path> + Send,
C: Codec + Send + 'static,
P: 'async_trait,
C: 'async_trait,
Self: Send + 'async_trait,
fn connect_timeout<'async_trait, P, C>(
path: P,
codec: C,
duration: Duration
) -> Pin<Box<dyn Future<Output = Result<Client<T, U>>> + Send + 'async_trait>> where
P: AsRef<Path> + Send,
C: Codec + Send + 'static,
P: 'async_trait,
C: 'async_trait,
Self: Send + 'async_trait,
Connect to a proxy unix socket, timing out after duration has passed
Auto Trait Implementations
impl<T, U> !RefUnwindSafe for Client<T, U>
impl<T, U> Send for Client<T, U>
impl<T, U> Sync for Client<T, U>
impl<T, U> Unpin for Client<T, U>
impl<T, U> !UnwindSafe for Client<T, U>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more