Trait DataStorage

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

A data storage protocol.

It is very similear to PacketTransfer trait, but implements should guarantee the persistence of the data when implementing DataStorage.

Required Methods§

Source

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

Connect to host. Most implments should make sure the server / other peer is avaliable.

Source

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

Try to download a data packet. Similear to ftp’s GET.

Source

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

Try to upload a data packet. Similear to ftp’s PUT.

Source

fn remove(&mut self, tag: &str) -> Result<(), String>

Remove the data packet from server.

Implementors§