Renames
This commit is contained in:
parent
b4512e4809
commit
451debedbb
19 changed files with 127 additions and 114 deletions
|
|
@ -11,13 +11,13 @@ use std::{
|
|||
path::Path,
|
||||
};
|
||||
|
||||
use crate::torrent_state::ManagedTorrentInfo;
|
||||
use crate::torrent_state::ManagedTorrentShared;
|
||||
|
||||
pub trait StorageFactory: Send + Sync + Any {
|
||||
type Storage: TorrentStorage;
|
||||
|
||||
fn create(&self, info: &ManagedTorrentInfo) -> anyhow::Result<Self::Storage>;
|
||||
fn create_and_init(&self, info: &ManagedTorrentInfo) -> anyhow::Result<Self::Storage> {
|
||||
fn create(&self, info: &ManagedTorrentShared) -> anyhow::Result<Self::Storage>;
|
||||
fn create_and_init(&self, info: &ManagedTorrentShared) -> anyhow::Result<Self::Storage> {
|
||||
let mut storage = self.create(info)?;
|
||||
storage.init(info)?;
|
||||
Ok(storage)
|
||||
|
|
@ -44,7 +44,7 @@ impl<SF: StorageFactory> StorageFactoryExt for SF {
|
|||
impl<SF: StorageFactory> StorageFactory for Wrapper<SF> {
|
||||
type Storage = Box<dyn TorrentStorage>;
|
||||
|
||||
fn create(&self, info: &ManagedTorrentInfo) -> anyhow::Result<Self::Storage> {
|
||||
fn create(&self, info: &ManagedTorrentShared) -> anyhow::Result<Self::Storage> {
|
||||
let s = self.sf.create(info)?;
|
||||
Ok(Box::new(s))
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ impl<SF: StorageFactory> StorageFactoryExt for SF {
|
|||
impl<U: StorageFactory + ?Sized> StorageFactory for Box<U> {
|
||||
type Storage = U::Storage;
|
||||
|
||||
fn create(&self, info: &ManagedTorrentInfo) -> anyhow::Result<U::Storage> {
|
||||
fn create(&self, info: &ManagedTorrentShared) -> anyhow::Result<U::Storage> {
|
||||
(**self).create(info)
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ impl<U: StorageFactory + ?Sized> StorageFactory for Box<U> {
|
|||
|
||||
pub trait TorrentStorage: Send + Sync {
|
||||
// Create/open files etc.
|
||||
fn init(&mut self, meta: &ManagedTorrentInfo) -> anyhow::Result<()>;
|
||||
fn init(&mut self, meta: &ManagedTorrentShared) -> anyhow::Result<()>;
|
||||
|
||||
/// Given a file_id (which you can get more info from in init_storage() through torrent info)
|
||||
/// read buf.len() bytes into buf at offset.
|
||||
|
|
@ -124,7 +124,7 @@ impl<U: TorrentStorage + ?Sized> TorrentStorage for Box<U> {
|
|||
(**self).remove_directory_if_empty(path)
|
||||
}
|
||||
|
||||
fn init(&mut self, meta: &ManagedTorrentInfo) -> anyhow::Result<()> {
|
||||
fn init(&mut self, meta: &ManagedTorrentShared) -> anyhow::Result<()> {
|
||||
(**self).init(meta)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue