pub trait ZxNetSocket {
// Required methods
fn packet_data(&self) -> &[u8] ⓘ;
fn begin_packet(&mut self);
fn push_byte(&mut self, byte: u8) -> usize;
fn outbound_index(&self) -> usize;
fn send_packet(&mut self);
fn recv_accept(&mut self) -> bool;
fn recv_packet(&mut self) -> bool;
fn pull_byte(&mut self) -> Option<u8>;
fn inbound_index(&self) -> usize;
fn send_accept(&mut self);
}Expand description
This trait is being used by ZxNet to send and receive ZX-NET packets to and from remote parties.
Required Methods§
Sourcefn packet_data(&self) -> &[u8] ⓘ
fn packet_data(&self) -> &[u8] ⓘ
Should return a view of the current packet being composed or received.
Sourcefn begin_packet(&mut self)
fn begin_packet(&mut self)
Signals that the new packet will be composed for sending.
Sourcefn push_byte(&mut self, byte: u8) -> usize
fn push_byte(&mut self, byte: u8) -> usize
Adds a byte to the packet data. Should return the size of the packet data after appending byte.
Sourcefn outbound_index(&self) -> usize
fn outbound_index(&self) -> usize
Should return the index of the next byte to be pushed to the outbound data packet. This is the same as the byte size of the composed data packet so far.
Sourcefn send_packet(&mut self)
fn send_packet(&mut self)
Should send the composed packet to the remote party.
Sourcefn recv_accept(&mut self) -> bool
fn recv_accept(&mut self) -> bool
Should optionally wait and get the confirmation from the remote party.
Returns true if the remote party confirmed the received packet.
Sourcefn recv_packet(&mut self) -> bool
fn recv_packet(&mut self) -> bool
Should receive a data packet from the remote party.
Returns true if the remote party has sent the next data packet.
Sourcefn pull_byte(&mut self) -> Option<u8>
fn pull_byte(&mut self) -> Option<u8>
Gets the next byte from the last received data packet.
Returns None if there are no more bytes to be returned.
Sourcefn inbound_index(&self) -> usize
fn inbound_index(&self) -> usize
Should return the index of the next byte to be pulled from the outbound data packet.
Sourcefn send_accept(&mut self)
fn send_accept(&mut self)
Should send the confirmation of the received packet to the remote party.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".