}
}
+#[derive(Clone)]
struct Caches {
/// The goodbye table cache maps goodbye table offsets to cache entries.
gbt_cache: Option<Arc<dyn Cache<u64, [GoodbyeItem]> + Send + Sync>>,
)
.await
}
+
+ pub fn set_goodbye_table_cache(
+ &mut self,
+ cache: Option<Arc<dyn Cache<u64, [GoodbyeItem]> + Send + Sync>>,
+ ) {
+ let new_caches = Arc::new(Caches {
+ gbt_cache: cache,
+ ..*self.caches
+ });
+ self.caches = new_caches;
+ }
}
impl<T: Clone + ReadAt> AccessorImpl<T> {
use std::os::unix::fs::FileExt;
use std::path::Path;
use std::pin::Pin;
+use std::sync::Arc;
use std::task::{Context, Poll};
-use crate::accessor::{self, ReadAt};
+use crate::accessor::{self, cache::Cache, ReadAt};
use crate::decoder::Decoder;
+use crate::format::GoodbyeItem;
use crate::util::poll_result_once;
use crate::Entry;
self.inner.open_root_ref(),
)?))
}
+
+ pub fn set_goodbye_table_cache<C>(&mut self, cache: Option<C>)
+ where
+ C: Cache<u64, [GoodbyeItem]> + Send + Sync + 'static,
+ {
+ self.inner
+ .set_goodbye_table_cache(cache.map(|cache| Arc::new(cache) as _))
+ }
}
impl<T: Clone + ReadAt> Accessor<T> {