diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-29 18:03:06 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-29 18:03:06 +0100 |
commit | db511d3fe50f05329615f718515fab1b80d9e06a (patch) | |
tree | 7969fea01be100cbe4385ad13a14940a987ac513 /common/src/impl.rs | |
parent | 82e8a55a1496ae9132e13e7286fe1c0d57d586d3 (diff) | |
download | jellything-db511d3fe50f05329615f718515fab1b80d9e06a.tar jellything-db511d3fe50f05329615f718515fab1b80d9e06a.tar.bz2 jellything-db511d3fe50f05329615f718515fab1b80d9e06a.tar.zst |
no direct redb access
Diffstat (limited to 'common/src/impl.rs')
-rw-r--r-- | common/src/impl.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/common/src/impl.rs b/common/src/impl.rs index a35216b..a98015a 100644 --- a/common/src/impl.rs +++ b/common/src/impl.rs @@ -3,7 +3,9 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin <metamuffin.org> */ -use crate::{ObjectIds, PeopleGroup, SourceTrack, SourceTrackKind, TmdbKind, TraktKind}; +use crate::{ + Node, NodeID, ObjectIds, PeopleGroup, SourceTrack, SourceTrackKind, TmdbKind, TraktKind, +}; use std::{fmt::Display, str::FromStr}; impl SourceTrackKind { @@ -146,3 +148,21 @@ impl FromStr for PeopleGroup { }) } } + +impl NodeID { + pub fn from_slug(slug: &str) -> Self { + let mut h = blake3::Hasher::new(); + h.update(slug.as_bytes()); + Self(*h.finalize().as_bytes()) + } + #[inline] + pub fn from_node(node: &Node) -> Self { + Self::from_slug(&node.slug) + } +} +impl Node { + #[inline] + pub fn id(&self) -> NodeID { + NodeID::from_node(self) + } +} |