use crate::{api::TorrentIdOrHash, bitv::BitV, type_aliases::BF}; #[async_trait::async_trait] pub trait BitVFactory: Send + Sync { async fn load(&self, id: TorrentIdOrHash) -> anyhow::Result>>; async fn clear(&self, id: TorrentIdOrHash) -> anyhow::Result<()>; async fn store_initial_check( &self, id: TorrentIdOrHash, b: BF, ) -> anyhow::Result>; } pub struct NonPersistentBitVFactory {} #[async_trait::async_trait] impl BitVFactory for NonPersistentBitVFactory { async fn load(&self, _: TorrentIdOrHash) -> anyhow::Result>> { Ok(None) } async fn clear(&self, _id: TorrentIdOrHash) -> anyhow::Result<()> { Ok(()) } async fn store_initial_check( &self, _id: TorrentIdOrHash, b: BF, ) -> anyhow::Result> { Ok(Box::new(b)) } }