use crate::dht::dht_protocol::{DhtCommand, DhtEvent, PeerData};
use lib3h_protocol::{data_types::EntryData, AddressRef, DidWork, Lib3hResult};
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct DhtConfig {
pub this_peer_address: String,
pub this_peer_transport: String,
pub custom: Vec<u8>,
}
pub type DhtFactory<D> = fn(config: &DhtConfig) -> Lib3hResult<D>;
pub trait Dht {
fn get_peer(&self, peer_address: &str) -> Option<PeerData>;
fn fetch_peer(&self, peer_address: &str) -> Option<PeerData>;
fn get_peer_list(&self) -> Vec<PeerData>;
fn this_peer(&self) -> &PeerData;
fn get_entry(&self, entry_address: &AddressRef) -> Option<EntryData>;
fn fetch_entry(&self, entry_address: &AddressRef) -> Option<EntryData>;
fn post(&mut self, cmd: DhtCommand) -> Lib3hResult<()>;
fn process(&mut self) -> Lib3hResult<(DidWork, Vec<DhtEvent>)>;
}