Skip to main content

ConnectEndpoint

Trait ConnectEndpoint 

Source
pub trait ConnectEndpoint<S: ?Sized>: Send + Sync {
    type Connection: Send;

    // Required method
    fn connect(
        &self,
        scheduler: &S,
        cancellation: &Cancellation,
    ) -> impl Future<Output = OperationResult<Self::Connection>> + Send;
}
Expand description

A reusable description of how to establish a connection. Consumers depend on this contract rather than DNS, addresses, or socket construction. S supplies explicit execution capabilities; the endpoint retains no scheduler and spawns no tasks.

Connection representation belongs to the implementation: a plain endpoint can return a scheduler socket, while a wrapper can return another transport. Errors preserve cooperative cancellation separately from I/O failure. Implementations must not retry cancellation as an ordinary connection failure.

Required Associated Types§

Source

type Connection: Send

The established transport, owned by the caller on success.

Required Methods§

Source

fn connect( &self, scheduler: &S, cancellation: &Cancellation, ) -> impl Future<Output = OperationResult<Self::Connection>> + Send

Establish one connection. Futures are lazy. Await completion after requesting cooperative cancellation so implementation-owned asynchronous cleanup can finish. Dropping a future abandons it and provides ordinary resource destruction, not an asynchronous cleanup guarantee.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§