use std::{
error::Error as StdError,
fmt::{self, Debug, Display, Formatter},
hash::Hash,
};
use datasize::DataSize;
use serde::{de::DeserializeOwned, Serialize};
use super::Tag;
#[derive(Clone, Copy, Eq, PartialEq, Serialize, Debug, DataSize)]
pub(crate) struct EmptyValidationMetadata;
impl Display for EmptyValidationMetadata {
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), fmt::Error> {
write!(formatter, "no validation metadata")
}
}
pub(crate) trait FetchItem:
Clone + Serialize + DeserializeOwned + Send + Sync + Debug + Display + Eq
{
type Id: Clone + Eq + Hash + Serialize + DeserializeOwned + Send + Sync + Debug + Display;
type ValidationError: StdError + Debug + Display;
type ValidationMetadata: Eq + Clone + Serialize + Debug + DataSize + Send;
const TAG: Tag;
fn fetch_id(&self) -> Self::Id;
fn validate(&self, metadata: &Self::ValidationMetadata) -> Result<(), Self::ValidationError>;
}