pub struct Endpoint(/* private fields */);
Expand description

An endpoint to the network that facilitates high-performance data transmission.

Endpoint encapsulates the necessary asynchronous/non-blocking handling of data transmission in the network. Each endpoint may contain at most one underlying Transport object at a time. It masks away the connection establishment, reconnection and other chores that need to be done by different means of network transmission. Its internal state EndpointState is kept (owned) by a Worker from the Driver and the worker will trigger the logic of the endpoint to help user move data to and from the contained transport object at its best effort. It offers to the user a nice and clear interface that one could asynchronously send to or receive from the network. It carries data across different contained transports (i.e., the transport object could be set and switched on-the-fly by Endpoint::set_transport), creates back pressure (aka. flow control) in its logic, although the underlying transport may not do so. The user does not have to care about whether the underlying transport is even active or not. If the transport provides a reliable channel, it guarantees reliable delivery. Otherwise, some data may still be lost due to the limitation of the specific transport implementation.

Implementations§

source§

impl Endpoint

source

pub fn inbound(&self) -> Receiver<'_>

Get an unsharable handle for receiving data.

source

pub fn outbound(&self) -> Sender

Get a sharable handle for sending data.

source

pub async fn set_transport( &self, transport: Box<dyn Transport> ) -> Result<&Self>

Load the endpoint with the given transport (replacing if exists). Initially, an endpoint starts without a transport.

source

pub async fn take_transport(&self) -> Result<Box<dyn Transport>>

Deregister the stream from the poll and take the transport out from the endpoint. The endpoint will be left without a transport.

source

pub async fn flush(&self) -> Result<&Self>

Try to flush the internal buffers in the endpoint. It is best-effort since the contained transport may not be available or able to transfer data.

source

pub async fn set_worker(&self, worker: Worker) -> Result<&Self>

Switch to be driven by a different worker. Each worker runs a sequential polling event loop. This could be used to load-balance the workers.

source

pub async fn worker(&self) -> Worker

Return the current worker.

source

pub async fn reset(&self) -> Result<&Self>

Reset the underlying transport. This will invoke shutdown() of the transport, causing the transport to eventually renew.

source

pub async fn is_disconnected(&self) -> Result<bool>

Return if the underlying transport of the endpoint is disconnected.

Trait Implementations§

source§

impl Clone for Endpoint

source§

fn clone(&self) -> Endpoint

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

Auto Trait Implementations§

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

§

type Output = T

Should always be Self
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