pub struct RawSocket<'a> { /* private fields */ }
Expand description
A raw IP socket.
A raw socket is bound to a specific IP protocol, and owns transmit and receive packet buffers.
Implementations
sourceimpl<'a> RawSocket<'a>
impl<'a> RawSocket<'a>
sourcepub fn new(
ip_version: IpVersion,
ip_protocol: IpProtocol,
rx_buffer: RawSocketBuffer<'a>,
tx_buffer: RawSocketBuffer<'a>
) -> RawSocket<'a>
pub fn new(
ip_version: IpVersion,
ip_protocol: IpProtocol,
rx_buffer: RawSocketBuffer<'a>,
tx_buffer: RawSocketBuffer<'a>
) -> RawSocket<'a>
Create a raw IP socket bound to the given IP version and datagram protocol, with the given buffers.
sourcepub fn register_recv_waker(&mut self, waker: &Waker)
pub fn register_recv_waker(&mut self, waker: &Waker)
Register a waker for receive operations.
The waker is woken on state changes that might affect the return value
of recv
method calls, such as receiving data, or the socket closing.
Notes:
- Only one waker can be registered at a time. If another waker was previously registered, it is overwritten and will no longer be woken.
- The Waker is woken only once. Once woken, you must register it again to receive more wakes.
- “Spurious wakes” are allowed: a wake doesn’t guarantee the result of
recv
has necessarily changed.
sourcepub fn register_send_waker(&mut self, waker: &Waker)
pub fn register_send_waker(&mut self, waker: &Waker)
Register a waker for send operations.
The waker is woken on state changes that might affect the return value
of send
method calls, such as space becoming available in the transmit
buffer, or the socket closing.
Notes:
- Only one waker can be registered at a time. If another waker was previously registered, it is overwritten and will no longer be woken.
- The Waker is woken only once. Once woken, you must register it again to receive more wakes.
- “Spurious wakes” are allowed: a wake doesn’t guarantee the result of
send
has necessarily changed.
sourcepub fn ip_version(&self) -> IpVersion
pub fn ip_version(&self) -> IpVersion
Return the IP version the socket is bound to.
sourcepub fn ip_protocol(&self) -> IpProtocol
pub fn ip_protocol(&self) -> IpProtocol
Return the IP protocol the socket is bound to.
sourcepub fn packet_recv_capacity(&self) -> usize
pub fn packet_recv_capacity(&self) -> usize
Return the maximum number packets the socket can receive.
sourcepub fn packet_send_capacity(&self) -> usize
pub fn packet_send_capacity(&self) -> usize
Return the maximum number packets the socket can transmit.
sourcepub fn payload_recv_capacity(&self) -> usize
pub fn payload_recv_capacity(&self) -> usize
Return the maximum number of bytes inside the recv buffer.
sourcepub fn payload_send_capacity(&self) -> usize
pub fn payload_send_capacity(&self) -> usize
Return the maximum number of bytes inside the transmit buffer.
sourcepub fn send(&mut self, size: usize) -> Result<&mut [u8]>
pub fn send(&mut self, size: usize) -> Result<&mut [u8]>
Enqueue a packet to send, and return a pointer to its payload.
This function returns Err(Error::Exhausted)
if the transmit buffer is full,
and Err(Error::Truncated)
if there is not enough transmit buffer capacity
to ever send this packet.
If the buffer is filled in a way that does not match the socket’s IP version or protocol, the packet will be silently dropped.
Note: The IP header is parsed and reserialized, and may not match the header actually transmitted bit for bit.
sourcepub fn send_slice(&mut self, data: &[u8]) -> Result<()>
pub fn send_slice(&mut self, data: &[u8]) -> Result<()>
Enqueue a packet to send, and fill it from a slice.
See also send.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for RawSocket<'a>
impl<'a> Send for RawSocket<'a>
impl<'a> Sync for RawSocket<'a>
impl<'a> Unpin for RawSocket<'a>
impl<'a> !UnwindSafe for RawSocket<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more