1#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3pub struct CacheKey {
4 namespace: String,
5 parts: Vec<String>,
6}
7
8impl CacheKey {
9 pub fn new(
11 namespace: impl Into<String>,
12 parts: impl IntoIterator<Item = impl Into<String>>,
13 ) -> Self {
14 Self {
15 namespace: namespace.into(),
16 parts: parts.into_iter().map(Into::into).collect(),
17 }
18 }
19
20 pub fn render(&self) -> String {
22 std::iter::once(self.namespace.as_str())
23 .chain(self.parts.iter().map(String::as_str))
24 .collect::<Vec<_>>()
25 .join(":")
26 }
27}