use crate::errors::Error;
use rustc_hash::FxHashMap;
use std::fmt::Debug;
use std::hash::Hash;
pub mod shared_adapter;
pub use shared_adapter::SharedPager;
pub mod mem;
pub use mem::MemPager64;
pub const DEFAULT_PAGE_SIZE_HINT: usize = 4096;
pub trait Pager {
type Id: Clone + Eq + Ord + Hash + Debug;
type Page: Clone + core::ops::Deref<Target = [u8]>;
fn read_batch(&self, ids: &[Self::Id]) -> Result<FxHashMap<Self::Id, Self::Page>, Error>;
fn write_batch(&self, pages: &[(Self::Id, &[u8])]) -> Result<(), Error>;
fn alloc_ids(&self, count: usize) -> Result<Vec<Self::Id>, Error>;
fn dealloc_ids(&self, ids: &[Self::Id]) -> Result<(), Error>;
fn page_size_hint(&self) -> Option<usize>;
fn materialize_owned(&self, bytes: &[u8]) -> Result<Self::Page, Error>;
fn on_root_changed(&self, _new_root: Self::Id) -> Result<(), Error> {
Ok(())
}
}