All storage factories are generic now
This commit is contained in:
parent
e4adfa569a
commit
5027d8ccd1
12 changed files with 88 additions and 52 deletions
|
|
@ -19,21 +19,21 @@ impl InMemoryPiece {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct InMemoryExampleStorageFactory {}
|
||||
|
||||
impl StorageFactory for InMemoryExampleStorageFactory {
|
||||
type Storage = InMemoryExampleStorage;
|
||||
|
||||
fn init_storage(
|
||||
&self,
|
||||
info: &crate::torrent_state::ManagedTorrentInfo,
|
||||
) -> anyhow::Result<Box<dyn TorrentStorage>> {
|
||||
Ok(Box::new(InMemoryExampleStorage::new(
|
||||
info.lengths,
|
||||
info.file_infos.clone(),
|
||||
)?))
|
||||
) -> anyhow::Result<InMemoryExampleStorage> {
|
||||
InMemoryExampleStorage::new(info.lengths, info.file_infos.clone())
|
||||
}
|
||||
}
|
||||
|
||||
struct InMemoryExampleStorage {
|
||||
pub struct InMemoryExampleStorage {
|
||||
lengths: Lengths,
|
||||
file_infos: FileInfos,
|
||||
map: RwLock<HashMap<ValidPieceIndex, InMemoryPiece>>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue