[][src]Trait hycon_rust::traits::PeerDB

pub trait PeerDB<KeyType, PeerType> {
    fn get(&self, key: &KeyType) -> Option<PeerType>;
fn get_all(&self) -> Option<Vec<PeerType>>;
fn get_multiple(&self, limit: usize) -> Option<Vec<PeerType>>;
fn inbound_connection(
        &mut self,
        key: KeyType,
        value: PeerType
    ) -> Result<(), Box<dyn Error>>;
fn outbound_connection(
        &mut self,
        key: KeyType,
        value: PeerType
    ) -> Result<(), Box<dyn Error>>;
fn connection_failure(
        &mut self,
        key: &KeyType
    ) -> Result<(), Box<dyn Error>>;
fn disconnect(&mut self, key: &KeyType);
fn put_multiple(
        &mut self,
        values: Vec<(KeyType, PeerType)>
    ) -> Result<(), Box<dyn Error>>;
fn get_recent(&self, limit: usize) -> Option<Vec<PeerType>>;
fn get_seen(&self, limit: usize) -> Option<Vec<PeerType>>;
fn get_oldest(&self, limit: usize) -> Option<Vec<PeerType>>;
fn get_random(&self, limit: usize) -> Option<Vec<PeerType>>; }

Defines methods required for a peer database implementation

Required methods

fn get(&self, key: &KeyType) -> Option<PeerType>

An Option containing the Peer corresponding to the given key, None if not found

fn get_all(&self) -> Option<Vec<PeerType>>

Gets all peers from the DB

fn get_multiple(&self, limit: usize) -> Option<Vec<PeerType>>

Gets multiple peers from the DB

fn inbound_connection(
    &mut self,
    key: KeyType,
    value: PeerType
) -> Result<(), Box<dyn Error>>

Handler for an inbound peer connection

fn outbound_connection(
    &mut self,
    key: KeyType,
    value: PeerType
) -> Result<(), Box<dyn Error>>

Handler for an outbound peer connection

fn connection_failure(&mut self, key: &KeyType) -> Result<(), Box<dyn Error>>

Handler for a connection failure

fn disconnect(&mut self, key: &KeyType)

Handler for a disconnect event

fn put_multiple(
    &mut self,
    values: Vec<(KeyType, PeerType)>
) -> Result<(), Box<dyn Error>>

Puts multiple peers into the DB

fn get_recent(&self, limit: usize) -> Option<Vec<PeerType>>

Get peers that have been seen recently

fn get_seen(&self, limit: usize) -> Option<Vec<PeerType>>

Gets list of seen peers

fn get_oldest(&self, limit: usize) -> Option<Vec<PeerType>>

Gets peer that is the oldest

fn get_random(&self, limit: usize) -> Option<Vec<PeerType>>

Gets a random peer

Loading content...

Implementors

impl PeerDB<SocketAddr, DBPeer> for PeerDatabase<SocketAddr, DBPeer>[src]

Loading content...