aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-12-08 19:53:12 +0100
committermetamuffin <metamuffin@disroot.org>2025-12-08 19:53:12 +0100
commit6edf0fd93abf7e58b4c0974e3d3e54bcf8517946 (patch)
tree32577db9d987897d4037ba9af0084b95b55e145c /common
parente4584a8135584e6591bac7d5397cf227cf3cff92 (diff)
downloadjellything-6edf0fd93abf7e58b4c0974e3d3e54bcf8517946.tar
jellything-6edf0fd93abf7e58b4c0974e3d3e54bcf8517946.tar.bz2
jellything-6edf0fd93abf7e58b4c0974e3d3e54bcf8517946.tar.zst
human-readable cache keys
Diffstat (limited to 'common')
-rw-r--r--common/src/helpers.rs23
-rw-r--r--common/src/lib.rs7
2 files changed, 4 insertions, 26 deletions
diff --git a/common/src/helpers.rs b/common/src/helpers.rs
index 431bf8c..d643aa6 100644
--- a/common/src/helpers.rs
+++ b/common/src/helpers.rs
@@ -4,9 +4,7 @@
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
-use base64::{Engine, prelude::BASE64_URL_SAFE};
-
-use crate::{CreditCategory, IdentifierType, Picture, PictureSlot};
+use crate::{CreditCategory, IdentifierType, PictureSlot};
use std::{fmt::Display, ops::Deref, str::FromStr};
#[derive(PartialEq)]
@@ -149,22 +147,3 @@ impl FromStr for PictureSlot {
})
}
}
-
-impl Display for Picture {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- f.write_str(&BASE64_URL_SAFE.encode(self.0))
- }
-}
-impl FromStr for Picture {
- type Err = &'static str;
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- let mut out = [0; 32];
- let size = BASE64_URL_SAFE
- .decode_slice(s, &mut out)
- .map_err(|_| "invalid base64 picture key")?;
- if size != out.len() {
- return Err("picture key parse invalid size");
- }
- Ok(Self(out))
- }
-}
diff --git a/common/src/lib.rs b/common/src/lib.rs
index cf79cc5..670d9af 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -68,7 +68,7 @@ pub struct Node {
pub federated: Option<String>,
pub tags: BTreeSet<String>,
pub ratings: BTreeMap<RatingType, f64>,
- pub pictures: BTreeMap<PictureSlot, Picture>,
+ pub pictures: BTreeMap<PictureSlot, Asset>,
pub credits: BTreeMap<CreditCategory, Vec<Appearance>>,
pub identifiers: BTreeMap<IdentifierType, String>,
pub visibility: Visibility,
@@ -104,9 +104,8 @@ pub enum IdentifierType {
Omdb,
}
-// TODO custom b64 ser
-#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Copy)]
-pub struct Picture(pub [u8; 32]);
+#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Hash)]
+pub struct Asset(pub String);
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Appearance {