2019-08-07 18:50:52 +02:00
|
|
|
use crate::{
|
|
|
|
cache::{Cache, Key},
|
|
|
|
service::Service,
|
|
|
|
};
|
|
|
|
use std::sync::{Arc, RwLock};
|
|
|
|
|
|
|
|
pub(crate) type State = Arc<RwLock<Cache<Key, String>>>;
|
|
|
|
|
2019-07-24 17:54:00 +02:00
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
pub(crate) struct FilePath {
|
|
|
|
pub(crate) user: String,
|
|
|
|
pub(crate) repo: String,
|
|
|
|
pub(crate) commit: String,
|
|
|
|
pub(crate) file: String,
|
|
|
|
}
|
|
|
|
|
2019-08-07 18:50:52 +02:00
|
|
|
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(),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|