Skip to main content

ZxNetSocket

Trait ZxNetSocket 

Source
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§

Source

fn packet_data(&self) -> &[u8]

Should return a view of the current packet being composed or received.

Source

fn begin_packet(&mut self)

Signals that the new packet will be composed for sending.

Source

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.

Source

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.

Source

fn send_packet(&mut self)

Should send the composed packet to the remote party.

Source

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.

Source

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.

Source

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.

Source

fn inbound_index(&self) -> usize

Should return the index of the next byte to be pulled from the outbound data packet.

Source

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".

Implementors§