Socket

Enum Socket 

Source
#[non_exhaustive]
pub enum Socket<const TIMER_HZ: u32, const L: usize> { Udp(UdpSocket<TIMER_HZ, L>), Tcp(TcpSocket<TIMER_HZ, L>), }
Expand description

A network socket.

This enumeration abstracts the various types of sockets based on the IP protocol. To downcast a Socket value to a concrete socket, use the AnySocket trait, e.g. to get UdpSocket, call UdpSocket::downcast(socket).

It is usually more convenient to use SocketSet::get instead.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Udp(UdpSocket<TIMER_HZ, L>)

§

Tcp(TcpSocket<TIMER_HZ, L>)

Implementations§

Source§

impl<const TIMER_HZ: u32, const L: usize> Socket<TIMER_HZ, L>

Source

pub fn handle(&self) -> SocketHandle

Return the socket handle.

Source

pub fn get_type(&self) -> SocketType

Source

pub fn should_update_available_data(&mut self, ts: Instant<TIMER_HZ>) -> bool

Source

pub fn available_data(&self) -> usize

Source

pub fn recycle(&self, ts: Instant<TIMER_HZ>) -> bool

Source

pub fn closed_by_remote(&mut self, ts: Instant<TIMER_HZ>)

Source

pub fn set_available_data(&mut self, available_data: usize)

Source

pub fn rx_enqueue_slice(&mut self, data: &[u8]) -> usize

Source

pub fn rx_window(&self) -> usize

Source

pub fn can_recv(&self) -> bool

Trait Implementations§

Source§

impl<const TIMER_HZ: u32, const L: usize> Debug for Socket<TIMER_HZ, L>

Source§

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

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

impl<const TIMER_HZ: u32, const L: usize> Into<Socket<TIMER_HZ, L>> for TcpSocket<TIMER_HZ, L>

Source§

fn into(self) -> Socket<TIMER_HZ, L>

Converts this type into the (usually inferred) input type.
Source§

impl<const TIMER_HZ: u32, const L: usize> Into<Socket<TIMER_HZ, L>> for UdpSocket<TIMER_HZ, L>

Source§

fn into(self) -> Socket<TIMER_HZ, L>

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<const TIMER_HZ: u32, const L: usize> Freeze for Socket<TIMER_HZ, L>

§

impl<const TIMER_HZ: u32, const L: usize> RefUnwindSafe for Socket<TIMER_HZ, L>

§

impl<const TIMER_HZ: u32, const L: usize> Send for Socket<TIMER_HZ, L>

§

impl<const TIMER_HZ: u32, const L: usize> Sync for Socket<TIMER_HZ, L>

§

impl<const TIMER_HZ: u32, const L: usize> Unpin for Socket<TIMER_HZ, L>

§

impl<const TIMER_HZ: u32, const L: usize> UnwindSafe for Socket<TIMER_HZ, L>

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> Same for T

Source§

type Output = T

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