[wip] unit testing
- doc for `file` module
This commit is contained in:
parent
b3bccbbf65
commit
4d47530326
3 changed files with 13 additions and 7 deletions
|
|
@ -181,7 +181,7 @@ impl CacheFile {
|
||||||
.take()
|
.take()
|
||||||
.expect("abort_upload called while not uploading");
|
.expect("abort_upload called while not uploading");
|
||||||
|
|
||||||
self.files.push_front(upl.into());
|
self.files.push_front(upl.stop());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn share_notify(&self, client: &impl Client) -> crate::Result<()> {
|
pub fn share_notify(&self, client: &impl Client) -> crate::Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,18 @@ use std::fmt;
|
||||||
|
|
||||||
use crate::sharry;
|
use crate::sharry;
|
||||||
|
|
||||||
|
/// Chunk of binary data belonging to a currently uploading file
|
||||||
pub struct Chunk<'t> {
|
pub struct Chunk<'t> {
|
||||||
|
/// id of the associated file
|
||||||
file_id: sharry::FileID,
|
file_id: sharry::FileID,
|
||||||
|
/// offset of this chunk in bytes
|
||||||
offset: u64,
|
offset: u64,
|
||||||
|
/// data inside this chunk
|
||||||
data: &'t [u8],
|
data: &'t [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Chunk<'_> {
|
impl fmt::Debug for Chunk<'_> {
|
||||||
|
// chunks are 1 MiB or more, we shouldn't print that
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("Chunk")
|
f.debug_struct("Chunk")
|
||||||
.field("file_id", &self.file_id)
|
.field("file_id", &self.file_id)
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,6 @@ pub struct Uploading {
|
||||||
offset: u64,
|
offset: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Uploading> for Checked {
|
|
||||||
fn from(value: Uploading) -> Self {
|
|
||||||
Self::new_direct(value.path, value.size, value.hash)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Uploading {
|
impl Uploading {
|
||||||
pub(super) fn new_direct(
|
pub(super) fn new_direct(
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
|
|
@ -118,6 +112,13 @@ impl Uploading {
|
||||||
Err(self.path)
|
Err(self.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// stop uploading this file
|
||||||
|
///
|
||||||
|
/// - consume self, returning as a `file::Checked`
|
||||||
|
pub fn stop(self) -> Checked {
|
||||||
|
Checked::new_direct(self.path, self.size, self.hash)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileTrait for Uploading {
|
impl FileTrait for Uploading {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue