Enum smoltcp::socket::Socket [] [src]

pub enum Socket<'a, 'b: 'a> {
    Raw(RawSocket<'a, 'b>),
    Udp(UdpSocket<'a, 'b>),
    Tcp(TcpSocket<'a>),
    // some variants omitted
}

A network socket.

This enumeration abstracts the various types of sockets based on the IP protocol. To downcast a Socket value down to a concrete socket, use the AsSocket trait, and call e.g. socket.as_socket::<UdpSocket<_>>().

The process and dispatch functions are fundamentally asymmetric and thus differ in their use of the trait PacketRepr. When process is called, the packet length is already known and no allocation is required; on the other hand, process would have to downcast a &PacketRepr to e.g. an &UdpRepr through Any, which is rather inelegant. Conversely, when dispatch is called, the packet length is not yet known and the packet storage has to be allocated; but the &PacketRepr is sufficient since the lower layers treat the packet as an opaque octet sequence.

Variants

Methods

impl<'a, 'b> Socket<'a, 'b>
[src]

[src]

Return the debug identifier.

[src]

Set the debug identifier.

The debug identifier is a number printed in socket trace messages. It could as well be used by the user code.

Trait Implementations

impl<'a, 'b: 'a> Debug for Socket<'a, 'b>
[src]

[src]

Formats the value using the given formatter.

impl<'a, 'b> AsSocket<RawSocket<'a, 'b>> for Socket<'a, 'b>
[src]

[src]

[src]

impl<'a, 'b> AsSocket<UdpSocket<'a, 'b>> for Socket<'a, 'b>
[src]

[src]

[src]

impl<'a, 'b> AsSocket<TcpSocket<'a>> for Socket<'a, 'b>
[src]

[src]

[src]