use std::net::IpAddr;
pub trait Node {
type Error: crate::traits::error::Error;
type Query: crate::traits::query::Query;
type QueryResponse: crate::traits::query::QueryResponse;
fn id(&self) -> u64;
fn query(&mut self, query: Self::Query) -> Result<Self::QueryResponse, Self::Error>;
fn ip(&self) -> IpAddr;
}
pub trait Network {
type Node: Node;
fn node_ids(&self) -> Vec<u64>;
fn node(&self, id: u64) -> Option<&Self::Node>;
fn execute_query(
&mut self,
sample_nodes: Vec<u64>,
query: <<Self as Network>::Node as Node>::Query,
) -> Result<
Vec<<<Self as Network>::Node as Node>::QueryResponse>,
<<Self as Network>::Node as Node>::Error,
>;
fn register_query_filter(
&mut self,
filter: fn(
query: <<Self as Network>::Node as Node>::Query,
originating_node: &Self::Node,
) -> bool,
) -> Result<(), <<Self as Network>::Node as Node>::Error>;
fn update_preferred_candidate(
&mut self,
candidate: <<<Self as Network>::Node as Node>::QueryResponse as crate::traits::query::QueryResponse>::Candidate,
);
}