Skip to content

Commit

Permalink
feat: add unit error
Browse files Browse the repository at this point in the history
  • Loading branch information
TroyKomodo committed Jul 13, 2024
1 parent b1bf1de commit a5aefe2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions foundations/src/batcher/dataloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ use super::{BatchOperation, Batcher, BatcherConfig, BatcherDataloader, BatcherEr
#[allow(type_alias_bounds)]
pub type LoaderOutput<L: Loader<S>, S: BuildHasher = RandomState> = Result<HashMap<L::Key, L::Value, S>, L::Error>;


#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct UnitError;

impl std::error::Error for UnitError {}

impl std::fmt::Display for UnitError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "unknown")
}
}

impl From<()> for UnitError {
fn from(_: ()) -> Self {
Self
}
}

pub trait Loader<S: BuildHasher + Default = RandomState> {
type Key: Clone + Eq + std::hash::Hash + Send + Sync;
type Value: Clone + Send + Sync;
Expand Down

0 comments on commit a5aefe2

Please sign in to comment.