Try to work on build some more.
This commit is contained in:
@@ -8,3 +8,28 @@ pub struct Class {
|
||||
pub path: PathBuf,
|
||||
pub checksum: String,
|
||||
}
|
||||
|
||||
impl Class {
|
||||
pub fn is_updated(&self) -> crate::Result<bool> {
|
||||
// If the path is local and that file has not been updated.
|
||||
Ok(self.checksum == sha256::try_digest(self.path.clone())?)
|
||||
}
|
||||
|
||||
pub fn update(&mut self) -> crate::Result<()> {
|
||||
self.checksum = sha256::try_digest(self.path.clone())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Make it clearer that this is for general files,
|
||||
// not nests.
|
||||
impl TryFrom<PathBuf> for Class {
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(value: PathBuf) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
path: value.clone(),
|
||||
checksum: sha256::try_digest(value)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user