pub struct FileManager { /* private fields */ }Implementations§
Source§impl FileManager
impl FileManager
Sourcepub fn new(data_dir: &Path) -> Result<Self>
pub fn new(data_dir: &Path) -> Result<Self>
data_dir is huddle’s per-user data directory; the cache lives
underneath at <data_dir>/files/cache.
pub fn cache_dir(&self) -> &Path
pub fn cache_path(&self, file_id: &str) -> PathBuf
Sourcepub fn read_cache(&self, file_id: &str) -> Result<Vec<u8>>
pub fn read_cache(&self, file_id: &str) -> Result<Vec<u8>>
Read a previously-completed transfer’s bytes from cache.
Sourcepub fn prepare_outgoing_from_path(&self, path: &Path) -> Result<OutgoingPlan>
pub fn prepare_outgoing_from_path(&self, path: &Path) -> Result<OutgoingPlan>
Build a transfer plan from an on-disk file.
Sourcepub fn prepare_outgoing_from_bytes(
&self,
name: &str,
mime: Option<String>,
bytes: Vec<u8>,
) -> Result<OutgoingPlan>
pub fn prepare_outgoing_from_bytes( &self, name: &str, mime: Option<String>, bytes: Vec<u8>, ) -> Result<OutgoingPlan>
Build a transfer plan from an in-memory blob (useful for the encrypted path, where the caller pre-encrypts a file).
Sourcepub fn accept_chunk(
&self,
file_id: &str,
chunk_index: u32,
total_chunks: u32,
data: Vec<u8>,
expected_size: u64,
) -> Result<Option<CompletedFile>>
pub fn accept_chunk( &self, file_id: &str, chunk_index: u32, total_chunks: u32, data: Vec<u8>, expected_size: u64, ) -> Result<Option<CompletedFile>>
Accept one chunk of an incoming transfer. Returns Some only on
the last chunk that completes the file (after SHA-256 verification).
Sourcepub fn cancel_incoming(&self, file_id: &str)
pub fn cancel_incoming(&self, file_id: &str)
Drop any partial state for an incoming transfer.
Auto Trait Implementations§
impl !Freeze for FileManager
impl RefUnwindSafe for FileManager
impl Send for FileManager
impl Sync for FileManager
impl Unpin for FileManager
impl UnsafeUnpin for FileManager
impl UnwindSafe for FileManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more