shrupl/src/file/mod.rs

29 lines
661 B
Rust
Raw Normal View History

mod checked;
mod chunk;
mod uploading;
2025-05-27 00:42:43 +00:00
use std::{ffi::OsStr, path::Path};
pub use checked::Checked;
pub use chunk::Chunk;
pub use uploading::Uploading;
2025-05-27 00:42:43 +00:00
pub trait FileTrait<'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")
}
/// get a reference to the file's name
fn get_name(&'t self) -> &'t str;
/// get the file's size
fn get_size(&self) -> u64;
}