Struct NetworkSession

Source
pub struct NetworkSession<Rx, Tx, C, const N: usize>
where Rx: Read<u8> + 'static, Tx: Write<u8> + 'static, C: SimpleClock,
{ /* private fields */ }
Expand description

A session with the typical network operations.

Implementations§

Source§

impl<Rx, Tx, C, const N: usize> NetworkSession<Rx, Tx, C, N>
where Rx: Read<u8> + 'static, Tx: Write<u8> + 'static, C: SimpleClock,

Source

pub fn listen(&mut self, port: u16) -> Result<()>

Begins to listen to the incoming TCP connections on the specified port.

Source

pub fn connect(&mut self, link_id: usize, address: SocketAddr) -> Result<()>

Establishes a TCP connection with the specified IP address, link identifier will be associated with the given IP address. Then it will be possible to send data using this link ID.

Source

pub fn poll_network_event(&mut self) -> Result<NetworkEvent<'_, N>, Error>

Non-blocking polling to get a new network event.

Source

pub fn send<I>(&mut self, link_id: usize, bytes: I) -> Result<()>
where I: Iterator<Item = u8> + ExactSizeIterator,

Sends data packet via the TCP socket with the link given identifier.

§Notes

No more than 2048 bytes can be sent at a time.

Source

pub fn get_info(&mut self) -> Result<SessionInfo>

Gets network session information.

Source

pub fn clock(&self) -> &C

Returns a reference to underlying clock instance.

Source

pub fn timeout(&self) -> Option<u64>

Returns an operations timeout.

Trait Implementations§

Source§

impl<Rx, Tx, C, const N: usize> Debug for NetworkSession<Rx, Tx, C, N>
where Rx: Read<u8> + 'static + Debug, Tx: Write<u8> + 'static + Debug, C: SimpleClock + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Rx, Tx, C, const N: usize> Freeze for NetworkSession<Rx, Tx, C, N>
where C: Freeze, Rx: Freeze, Tx: Freeze,

§

impl<Rx, Tx, C, const N: usize> RefUnwindSafe for NetworkSession<Rx, Tx, C, N>

§

impl<Rx, Tx, C, const N: usize> Send for NetworkSession<Rx, Tx, C, N>
where C: Send, Rx: Send, Tx: Send,

§

impl<Rx, Tx, C, const N: usize> Sync for NetworkSession<Rx, Tx, C, N>
where C: Sync, Rx: Sync, Tx: Sync,

§

impl<Rx, Tx, C, const N: usize> Unpin for NetworkSession<Rx, Tx, C, N>
where C: Unpin, Rx: Unpin, Tx: Unpin,

§

impl<Rx, Tx, C, const N: usize> UnwindSafe for NetworkSession<Rx, Tx, C, N>
where C: UnwindSafe, Rx: UnwindSafe, Tx: UnwindSafe,

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.