move simplified SharryFile trait back into mod.rs
This commit is contained in:
parent
e908c09beb
commit
e208df9711
3 changed files with 22 additions and 27 deletions
|
|
@ -1,22 +0,0 @@
|
||||||
use std::{
|
|
||||||
ffi::OsStr,
|
|
||||||
fmt::{Debug, Display},
|
|
||||||
path::Path,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub trait SharryFile<'t> {
|
|
||||||
/// extract the filename part of a `Path` reference
|
|
||||||
///
|
|
||||||
/// # Panics
|
|
||||||
///
|
|
||||||
/// Expects `path::Path::file_name` and `ffi::OsStr::to_str` to succeed on the given path
|
|
||||||
fn extract_file_name(p: &'t Path) -> &'t str {
|
|
||||||
p.file_name()
|
|
||||||
.and_then(OsStr::to_str)
|
|
||||||
.expect("bad file name")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_name(&'t self) -> &'t str;
|
|
||||||
|
|
||||||
fn get_size(&self) -> u64;
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,26 @@
|
||||||
mod checked;
|
mod checked;
|
||||||
mod filetrait;
|
|
||||||
mod uploading;
|
mod uploading;
|
||||||
|
|
||||||
|
use std::{ffi::OsStr, path::Path};
|
||||||
|
|
||||||
pub use checked::FileChecked;
|
pub use checked::FileChecked;
|
||||||
pub use filetrait::SharryFile;
|
|
||||||
pub use uploading::{ChunkState, FileUploading, UploadError};
|
pub use uploading::{ChunkState, FileUploading, UploadError};
|
||||||
|
|
||||||
use super::{Alias, Share, alias::SharryAlias};
|
use super::{Alias, Share, alias::SharryAlias};
|
||||||
|
|
||||||
|
pub trait SharryFile<'t> {
|
||||||
|
/// extract the filename part of a `Path` reference
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Expects `path::Path::file_name` and `ffi::OsStr::to_str` to succeed on the given path
|
||||||
|
fn extract_file_name(p: &'t Path) -> &'t str {
|
||||||
|
p.file_name()
|
||||||
|
.and_then(OsStr::to_str)
|
||||||
|
.expect("bad file name")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_name(&'t self) -> &'t str;
|
||||||
|
|
||||||
|
fn get_size(&self) -> u64;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@ impl std::fmt::Display for FileUploading {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"Uploading ({:?}, {}, {})",
|
"Uploading {:?} ({}/{})",
|
||||||
self.path.display(),
|
self.path.display(),
|
||||||
self.size,
|
self.offset,
|
||||||
self.offset
|
self.size
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue