Redifine origin::mux to be actually usable

This commit is contained in:
Brian Picciano 2024-05-30 23:46:01 +02:00
parent 3a24e5649e
commit a04855a252

View File

@ -1,27 +1,24 @@
use crate::error::unexpected::Mappable; use crate::error::unexpected::Mappable;
use crate::{origin, util}; use crate::{origin, util};
use std::sync::Arc;
pub struct Store<F, S> pub struct Store<F>
where where
F: Fn(&origin::Descr) -> Option<S> + Sync + Send, F: Fn(&origin::Descr) -> Option<Arc<dyn origin::Store + Sync + Send>> + Sync + Send,
{ {
mapping_fn: F, mapping_fn: F,
} }
impl<F, S> Store<F, S> pub fn new<F>(mapping_fn: F) -> Store<F>
where where
S: origin::Store + Sync + Send + 'static, F: Fn(&origin::Descr) -> Option<Arc<dyn origin::Store + Sync + Send>> + Sync + Send,
F: Fn(&origin::Descr) -> Option<S> + Sync + Send,
{ {
pub fn new(mapping_fn: F) -> Store<F, S> {
Store { mapping_fn } Store { mapping_fn }
}
} }
impl<F, S> origin::Store for Store<F, S> impl<F> origin::Store for Store<F>
where where
S: origin::Store + Sync + Send + 'static, F: Fn(&origin::Descr) -> Option<Arc<dyn origin::Store + Sync + Send>> + Sync + Send,
F: Fn(&origin::Descr) -> Option<S> + Sync + Send,
{ {
fn sync(&self, descr: &origin::Descr) -> util::BoxFuture<'_, Result<(), origin::SyncError>> { fn sync(&self, descr: &origin::Descr) -> util::BoxFuture<'_, Result<(), origin::SyncError>> {
let descr = descr.clone(); let descr = descr.clone();