Trait StreamTransfer

Source
pub trait StreamTransfer {
    // Required methods
    fn connect(&mut self) -> Result<(), String>;
    fn recv(&mut self) -> Result<Option<Vec<u8>>, String>;
    fn peek(&mut self) -> Result<Option<Vec<u8>>, String>;
    fn send(&mut self, data: Vec<u8>) -> Result<(), String>;
}
Expand description

A stream transfer protocol.

Required Methods§

Source

fn connect(&mut self) -> Result<(), String>

Connect to stream. Most implments should do two things here:

  1. Connect to the stream.
  2. Make sure the server / other peer is online and active.
Source

fn recv(&mut self) -> Result<Option<Vec<u8>>, String>

Try to receive a data packet and remove it from queue.

Source

fn peek(&mut self) -> Result<Option<Vec<u8>>, String>

Try to receive a data packet.

Source

fn send(&mut self, data: Vec<u8>) -> Result<(), String>

Send a data packet to the server / other peer.

Implementors§