Struct glommio::net::AcceptedUnixStream[][src]

pub struct AcceptedUnixStream { /* fields omitted */ }
Expand description

An Accepted Unix connection that can be moved to a different executor

This is useful in situations where the load balancing provided by the Operating System through ReusePort is not desirable. The user can accept the connection in one executor through shared_accept which returns an AcceptedUnixStream.

Once the AcceptedUnixStream arrives at its destination it can then be made active with bind_to_executor

Implementations

Binds this AcceptedUnixStream to the current executor

This returns a UnixStream that can then be used normally

Examples

use glommio::{
    channels::shared_channel,
    net::UnixListener,
    LocalExecutor,
    LocalExecutorBuilder,
};

let ex = LocalExecutor::default();
ex.run(async move {
    let (sender, receiver) = shared_channel::new_bounded(1);
    let sender = sender.connect().await;

    let listener = UnixListener::bind("/tmp/named").unwrap();

    let accepted = listener.shared_accept().await.unwrap();
    sender.try_send(accepted).unwrap();

    let ex1 = LocalExecutorBuilder::new()
        .spawn(move || async move {
            let receiver = receiver.connect().await;
            let accepted = receiver.recv().await.unwrap();
            let _ = accepted.bind_to_executor();
        })
        .unwrap();

    ex1.join().unwrap();
});

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more