Skip to main content

TokioSoeSocket

Struct TokioSoeSocket 

Source
pub struct TokioSoeSocket { /* private fields */ }
Expand description

An async SOE socket: a SoeMultiplexer driven over a Tokio UDP socket.

Drive it by repeatedly awaiting step, which performs a single read-or-tick cycle and returns any SocketEvents produced. Sessions are initiated with connect and data is sent with enqueue_data.

Implementations§

Source§

impl TokioSoeSocket

Source

pub async fn bind( local: SocketAddr, config: SocketConfig, tick_period: Duration, ) -> Result<Self>

Binds a UDP socket to local and prepares to drive sessions, ticking every tick_period. A period of 1–10ms is typical.

Source

pub fn local_addr(&self) -> Result<SocketAddr>

Returns the local address the socket is bound to.

Source

pub async fn step(&mut self) -> Result<Vec<SocketEvent<SocketAddr>>>

Performs a single drive cycle: awaits either an incoming datagram or the next tick, runs a session tick, flushes outgoing datagrams, and returns any events.

Trait Implementations§

Source§

impl Debug for TokioSoeSocket

Source§

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

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

impl SoeSocket for TokioSoeSocket

Source§

fn local_addr(&self) -> Result<SocketAddr>

Returns the local address the underlying socket is bound to.
Source§

fn session_count(&self) -> usize

Returns the number of active sessions.
Source§

fn connect(&mut self, remote: SocketAddr)

Opens a client session to remote. The session request is sent on the next drive step.
Source§

fn enqueue_data(&mut self, remote: &SocketAddr, data: &[u8]) -> bool

Enqueues application data to be sent reliably to remote. Returns false if there is no running session for that address.
Source§

fn terminate(&mut self, remote: &SocketAddr, reason: DisconnectReason)

Terminates the session with remote, notifying the remote party.

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.