diff --git a/src/models/blob.rs b/src/models/blob.rs index 14dc96a..c3fc7fc 100644 --- a/src/models/blob.rs +++ b/src/models/blob.rs @@ -1,7 +1,8 @@ +use crate::models::object::Hash; +use crate::store::Store; +use crate::utils::util::calc_hash; use std::fs; use std::path::Path; -use crate::models::object::Hash; -use crate::utils::util::calc_hash; /** Blob @@ -19,7 +20,22 @@ impl Blob { let hash = calc_hash(&data); Blob { hash, data } } + + pub fn load(hash: &String) -> Blob { + let s = Store::new(); + let data = s.load(hash); + Blob { + hash: hash.clone(), + data, + } + } + + pub fn save(&self) { + let s = Store::new(); + s.save(&self.data); + } + pub fn get_hash(&self) -> String { self.hash.clone() } -} \ No newline at end of file +} diff --git a/src/store.rs b/src/store.rs index ed53d59..a0c4e66 100644 --- a/src/store.rs +++ b/src/store.rs @@ -41,7 +41,6 @@ impl Store { } #[cfg(test)] mod tests { - use crate::commands::init; use super::*;