use std::ops::Range;
use std::time::Instant;
use crate::common::{DatabaseId, Entry};
pub trait NodeTable<Id: DatabaseId + Clone + 'static, Info: Clone + 'static> {
fn buckets(&self) -> usize;
fn create_or_update(&mut self, node: &Entry<Id, Info>) -> bool;
fn nearest(&self, id: &Id, range: Range<usize>) -> Vec<Entry<Id, Info>>;
fn contains(&self, id: &Id) -> Option<Entry<Id, Info>>;
fn oldest(&self, index: usize) -> Option<Entry<Id, Info>>;
fn update_entry<F>(&mut self, id: &Id, f: F) -> bool
where
F: Fn(&mut Entry<Id, Info>);
fn remove_entry(&mut self, id: &Id);
fn bucket_info(&self) -> Vec<BucketInfo>;
}
pub struct BucketInfo {
pub index: usize,
pub nodes: usize,
pub updated: Option<Instant>,
}