use crate::service; use std::sync::{Arc, RwLock}; use time_cache::Cache; pub(crate) type State = Arc>>; #[derive(Deserialize, Debug)] pub(crate) struct FilePath { pub(crate) user: Arc, pub(crate) repo: Arc, pub(crate) commit: Arc, pub(crate) file: Arc, } 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(), ) } } #[derive(Eq, PartialEq, Hash, Debug)] pub(crate) struct Key(Service, Arc, Arc, Arc); #[derive(Eq, PartialEq, Hash, Debug)] pub(crate) enum Service { GitHub, GitLab, Bitbucket, } impl Key { pub(crate) fn new( service: Service, user: Arc, repo: Arc, branch: Arc, ) -> Self { Key(service, user, repo, branch) } }