Trait InterfaceIO

Source
pub trait InterfaceIO: Debug {
Show 22 methods // Required methods fn send_message<'life0, 'life1, 'async_trait>( &'life0 self, peer_index: u64, buffer: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn send_message_to_all<'life0, 'life1, 'async_trait>( &'life0 self, buffer: &'life1 [u8], excluded_peers: Vec<u64>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn connect_to_peer<'life0, 'async_trait>( &'life0 mut self, url: String, peer_index: PeerIndex, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn disconnect_from_peer<'life0, 'async_trait>( &'life0 self, peer_index: u64, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn fetch_block_from_peer<'life0, 'life1, 'async_trait>( &'life0 self, block_hash: SaitoHash, peer_index: u64, url: &'life1 str, block_id: BlockId, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn write_value<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn append_value<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, key: &'life1 str, value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn flush_data<'life0, 'life1, 'async_trait>( &'life0 mut self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn read_value<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn load_block_file_list<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn is_existing_file<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove_value<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_block_dir(&self) -> String; fn get_checkpoint_dir(&self) -> String; fn ensure_block_directory_exists( &self, block_dir: &str, ) -> Result<(), Error>; fn process_api_call<'life0, 'async_trait>( &'life0 self, buffer: Vec<u8>, msg_index: u32, peer_index: PeerIndex, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn process_api_success<'life0, 'async_trait>( &'life0 self, buffer: Vec<u8>, msg_index: u32, peer_index: PeerIndex, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn process_api_error<'life0, 'async_trait>( &'life0 self, buffer: Vec<u8>, msg_index: u32, peer_index: PeerIndex, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn send_interface_event(&self, event: InterfaceEvent); fn save_wallet<'life0, 'life1, 'async_trait>( &'life0 self, wallet: &'life1 mut Wallet, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn load_wallet<'life0, 'life1, 'async_trait>( &'life0 self, wallet: &'life1 mut Wallet, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_my_services(&self) -> Vec<PeerService>;
}
Expand description

An interface is provided to access the IO functionalities in a platform (Rust/WASM) agnostic way

Required Methods§

Source

fn send_message<'life0, 'life1, 'async_trait>( &'life0 self, peer_index: u64, buffer: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn send_message_to_all<'life0, 'life1, 'async_trait>( &'life0 self, buffer: &'life1 [u8], excluded_peers: Vec<u64>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sends the given message buffer to all the peers except the ones specified

§Arguments
  • message_name:
  • buffer:
  • peer_exceptions: Peer indices for which this message should not be sent

returns: Result<(), Error>

§Examples
Source

fn connect_to_peer<'life0, 'async_trait>( &'life0 mut self, url: String, peer_index: PeerIndex, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Connects to the peer with given configuration

§Arguments
  • peer:

returns: Result<(), Error>

§Examples
Source

fn disconnect_from_peer<'life0, 'async_trait>( &'life0 self, peer_index: u64, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn fetch_block_from_peer<'life0, 'life1, 'async_trait>( &'life0 self, block_hash: SaitoHash, peer_index: u64, url: &'life1 str, block_id: BlockId, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches a block with given hash from a specific peer

§Arguments
  • block_hash:
  • peer_index:
  • url:

returns: Result<(), Error>

§Examples
Source

fn write_value<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Writes a value to a persistent storage with the given key

§Arguments
  • key:
  • value:

returns: Result<(), Error>

§Examples
Source

fn append_value<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, key: &'life1 str, value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn flush_data<'life0, 'life1, 'async_trait>( &'life0 mut self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn read_value<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads a value with the given key from a persistent storage

§Arguments
  • key:

returns: Result<Vec<u8, Global>, Error>

§Examples
Source

fn load_block_file_list<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads the block path list from the persistent storage

Source

fn is_existing_file<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn remove_value<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes the value with the given key from the persistent storage

Source

fn get_block_dir(&self) -> String

Retrieve the prefix for all the keys for blocks

Source

fn get_checkpoint_dir(&self) -> String

Source

fn ensure_block_directory_exists(&self, block_dir: &str) -> Result<(), Error>

Source

fn process_api_call<'life0, 'async_trait>( &'life0 self, buffer: Vec<u8>, msg_index: u32, peer_index: PeerIndex, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn process_api_success<'life0, 'async_trait>( &'life0 self, buffer: Vec<u8>, msg_index: u32, peer_index: PeerIndex, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn process_api_error<'life0, 'async_trait>( &'life0 self, buffer: Vec<u8>, msg_index: u32, peer_index: PeerIndex, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn send_interface_event(&self, event: InterfaceEvent)

Source

fn save_wallet<'life0, 'life1, 'async_trait>( &'life0 self, wallet: &'life1 mut Wallet, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn load_wallet<'life0, 'life1, 'async_trait>( &'life0 self, wallet: &'life1 mut Wallet, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn get_my_services(&self) -> Vec<PeerService>

Implementors§