Helper methods
This commit is contained in:
parent
566f4c0e01
commit
b65df17a4e
@ -1,3 +1,11 @@
|
|||||||
|
use crate::{
|
||||||
|
cache::{Cache, Key},
|
||||||
|
service::Service,
|
||||||
|
};
|
||||||
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
|
pub(crate) type State = Arc<RwLock<Cache<Key, String>>>;
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub(crate) struct FilePath {
|
pub(crate) struct FilePath {
|
||||||
pub(crate) user: String,
|
pub(crate) user: String,
|
||||||
@ -6,3 +14,17 @@ pub(crate) struct FilePath {
|
|||||||
pub(crate) file: String,
|
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<T: Service>(&self) -> Key {
|
||||||
|
Key::new(
|
||||||
|
T::cache_service(),
|
||||||
|
self.user.clone(),
|
||||||
|
self.repo.clone(),
|
||||||
|
self.commit.clone(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user