#![warn(missing_docs)]
#![warn(broken_intra_doc_links)]
use std::error;
use std::io;
#[derive(Debug)]
pub enum ForcepError {
Io(io::Error),
MetaDe(bson::de::Error),
MetaSer(bson::ser::Error),
MetaDb(sled::Error),
MetaNotFound,
NotFound,
}
pub type Error = ForcepError;
pub type Result<T> = std::result::Result<T, ForcepError>;
impl std::fmt::Display for ForcepError {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Io(e) => write!(fmt, "an I/O error occurred: {}", e),
Self::MetaDe(e) => write!(fmt, "there was a problem deserializing metadata: {}", e),
Self::MetaSer(e) => write!(fmt, "there was a problem serializing metadata: {}", e),
Self::MetaDb(e) => write!(fmt, "an error with the metadata database occurred: {}", e),
Self::MetaNotFound => write!(fmt, "the entry for the key provided was found, but the metadata was strangely not present"),
Self::NotFound => write!(fmt, "the entry for the key provided was not found"),
}
}
}
impl error::Error for ForcepError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Self::Io(e) => Some(e),
Self::MetaDe(e) => Some(e),
Self::MetaSer(e) => Some(e),
Self::MetaDb(e) => Some(e),
Self::MetaNotFound => None,
Self::NotFound => None,
}
}
}
mod mem_cache;
mod tmp;
mod builder;
pub use builder::CacheBuilder;
mod cache;
pub use cache::Cache;
mod metadata;
pub(crate) use metadata::MetaDb;
pub use metadata::{Md5Bytes, Metadata};
pub mod evictors;