Struct distant_net::client::Client

source ·
pub struct Client<T, U> { /* private fields */ }
Expand description

Represents a client that can be used to send requests & receive responses from a server.

Implementations§

source§

impl<T, U> Client<T, U>where T: Send + Sync + Serialize + 'static, U: Send + Sync + DeserializeOwned + 'static,

source

pub fn into_untyped_client(self) -> UntypedClient

Consumes the client, returning an untyped variant.

source

pub fn spawn_inmemory( transport: FramedTransport<InmemoryTransport>, config: ClientConfig ) -> Self

Spawns a client using the provided FramedTransport of InmemoryTransport and a specific ReconnectStrategy.

Note

This will NOT perform any handshakes or authentication procedures nor will it replay any missing frames. This is to be used when establishing a Client to be run internally within a program.

source§

impl Client<(), ()>

source

pub fn build() -> ClientBuilder<(), ()>

Creates a new ClientBuilder.

source

pub fn tcp<T>( connector: impl Into<TcpConnector<T>> ) -> ClientBuilder<(), TcpConnector<T>>

Creates a new ClientBuilder configured to use a TcpConnector.

source

pub fn unix_socket( connector: impl Into<UnixSocketConnector> ) -> ClientBuilder<(), UnixSocketConnector>

Creates a new ClientBuilder configured to use a UnixSocketConnector.

source§

impl<T, U> Client<T, U>

source

pub fn into_channel(self) -> Channel<T, U>

Convert into underlying channel.

source

pub fn clone_channel(&self) -> Channel<T, U>

Clones the underlying channel for requests and returns the cloned instance.

source

pub async fn wait(self) -> Result<()>

Waits for the client to terminate, which resolves when the receiving end of the network connection is closed (or the client is shutdown). Returns whether or not the client exited successfully or due to an error.

source

pub fn abort(&self)

Abort the client’s current connection by forcing its tasks to abort.

source

pub fn clone_shutdown(&self) -> Box<dyn Shutdown>

Clones the underlying shutdown signaler for the client. This enables you to wait on the client while still having the option to shut it down from somewhere else.

source

pub async fn shutdown(&self) -> Result<()>

Signal for the client to shutdown its connection cleanly.

source

pub fn will_shutdown_on_drop(&mut self) -> bool

Returns whether the client should fully shutdown once it is dropped. If true, this will result in all channels tied to the client no longer functioning once the client is dropped.

source

pub fn shutdown_on_drop(&mut self, shutdown_on_drop: bool)

Sets whether the client should fully shutdown once it is dropped. If true, this will result in all channels tied to the client no longer functioning once the client is dropped.

source

pub fn clone_connection_watcher(&self) -> ConnectionWatcher

Clones the underlying [ConnectionStateWatcher] for the client.

source

pub fn on_connection_change<F>(&self, f: F) -> JoinHandle<()>where F: FnMut(ConnectionState) + Send + 'static,

Spawns a new task that continually monitors for connection changes and invokes the function f whenever a new change is detected.

source

pub fn is_finished(&self) -> bool

Returns true if client’s underlying event processing has finished/terminated.

source§

impl Client<ManagerRequest, ManagerResponse>

source

pub async fn launch( &mut self, destination: impl Into<Destination>, options: impl Into<Map>, handler: impl AuthHandler + Send ) -> Result<Destination>

Request that the manager launches a new server at the given destination with options being passed for destination-specific details, returning the new destination of the spawned server.

The provided handler will be used for any authentication requirements when connecting to the remote machine to spawn the server.

source

pub async fn connect( &mut self, destination: impl Into<Destination>, options: impl Into<Map>, handler: impl AuthHandler + Send ) -> Result<ConnectionId>

Request that the manager establishes a new connection at the given destination with options being passed for destination-specific details.

The provided handler will be used for any authentication requirements when connecting to the server.

source

pub async fn open_raw_channel( &mut self, connection_id: ConnectionId ) -> Result<RawChannel>

Establishes a channel with the server represented by the connection_id, returning a RawChannel acting as the connection.

Note

Multiple calls to open a channel against the same connection will result in establishing a duplicate channel to the same server, so take care when using this method.

source

pub async fn version(&mut self) -> Result<SemVer>

Retrieves the version of the manager.

source

pub async fn info(&mut self, id: ConnectionId) -> Result<ConnectionInfo>

Retrieves information about a specific connection

source

pub async fn kill(&mut self, id: ConnectionId) -> Result<()>

Kills the specified connection

source

pub async fn list(&mut self) -> Result<ConnectionList>

Retrieves a list of active connections

Methods from Deref<Target = Channel<T, U>>§

source

pub fn is_closed(&self) -> bool

Returns true if no more requests can be transferred

source

pub async fn assign_default_mailbox( &self, buffer: usize ) -> Result<Mailbox<Response<U>>>

Assigns a default mailbox for any response received that does not match another mailbox.

source

pub async fn remove_default_mailbox(&self) -> Result<()>

Removes the default mailbox used for unmatched responses such that any response without a matching mailbox will be dropped.

source

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

source

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

source

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

source

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

source

pub async fn fire(&mut self, req: impl Into<Request<T>>) -> Result<()>

Sends a request without waiting for a response; this method is able to be used even if the session’s receiving line to the remote server has been severed

source

pub async fn fire_timeout( &mut self, req: impl Into<Request<T>>, duration: impl Into<Option<Duration>> ) -> Result<()>

Sends a request without waiting for a response, timing out after duration has passed

Trait Implementations§

source§

impl<T, U> Debug for Client<T, U>

source§

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

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

impl<T, U> Deref for Client<T, U>

§

type Target = Channel<T, U>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T, U> DerefMut for Client<T, U>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<T, U> Drop for Client<T, U>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T, U> From<Client<T, U>> for Channel<T, U>

source§

fn from(client: Client<T, U>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T, U> !RefUnwindSafe for Client<T, U>

§

impl<T, U> Send for Client<T, U>where T: Send, U: Send,

§

impl<T, U> Sync for Client<T, U>where T: Sync, U: Sync,

§

impl<T, U> Unpin for Client<T, U>where T: Unpin, U: Unpin,

§

impl<T, U> !UnwindSafe for Client<T, U>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for Twhere T: 'static,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Converts mutable reference to Any
source§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Consumes and produces Box<dyn Any>
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V