1cac9ab924
The `0.1.0` release is coming up, and a prerequisite to publish to crates.io is to not depend on any non crates.io dependency. We're using the `{binary_bytes_per_sec}` formatting spec, which is only in my fork. I published my fork to crates.io as `imdl-indicatif`, and this diff starts depending on that fork. type: distribution
38 lines
662 B
Rust
38 lines
662 B
Rust
use crate::common::*;
|
|
|
|
#[derive(Debug)]
|
|
pub(crate) struct FileStatus {
|
|
path: FilePath,
|
|
error: Option<FileError>,
|
|
}
|
|
|
|
impl FileStatus {
|
|
pub(crate) fn status(
|
|
absolute: &Path,
|
|
path: FilePath,
|
|
length: Bytes,
|
|
md5: Option<Md5Digest>,
|
|
) -> Self {
|
|
let error = FileError::verify(absolute, length, md5).err();
|
|
|
|
FileStatus { path, error }
|
|
}
|
|
|
|
pub(crate) fn is_good(&self) -> bool {
|
|
self.error.is_none()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
pub(crate) fn is_bad(&self) -> bool {
|
|
!self.is_good()
|
|
}
|
|
|
|
pub(crate) fn error(&self) -> Option<&FileError> {
|
|
self.error.as_ref()
|
|
}
|
|
|
|
pub(crate) fn path(&self) -> &FilePath {
|
|
&self.path
|
|
}
|
|
}
|