diff --git a/backend/src/data.rs b/backend/src/data.rs index d68166e..5439e68 100644 --- a/backend/src/data.rs +++ b/backend/src/data.rs @@ -1,3 +1,11 @@ +use crate::{ + cache::{Cache, Key}, + service::Service, +}; +use std::sync::{Arc, RwLock}; + +pub(crate) type State = Arc>>; + #[derive(Deserialize, Debug)] pub(crate) struct FilePath { pub(crate) user: String, @@ -6,3 +14,17 @@ pub(crate) struct FilePath { pub(crate) file: String, } +impl FilePath { + pub(crate) fn path(&self) -> String { + format!("{}/{}/{}/{}", self.user, self.repo, self.commit, self.file) + } + + pub(crate) fn to_key(&self) -> Key { + Key::new( + T::cache_service(), + self.user.clone(), + self.repo.clone(), + self.commit.clone(), + ) + } +}