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
Raw(RawSocket<'a, 'b>)
Udp(UdpSocket<'a, 'b>)
Tcp(TcpSocket<'a>)
Methods
impl<'a, 'b> Socket<'a, 'b>
[src]
fn debug_id(&self) -> usize
[src]
Return the debug identifier.
fn set_debug_id(&mut self, id: usize)
[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.