various: add Display impls for domain enums; improve contextual errors

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia16e7e34cda6ae3e12590ea1ea9268486a6a6964
This commit is contained in:
raf 2026-03-07 16:55:43 +03:00
commit cd63eeccff
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
6 changed files with 143 additions and 77 deletions

View file

@ -181,6 +181,23 @@ pub enum CustomFieldType {
Boolean,
}
impl CustomFieldType {
pub fn as_str(&self) -> &'static str {
match self {
Self::Text => "text",
Self::Number => "number",
Self::Date => "date",
Self::Boolean => "boolean",
}
}
}
impl std::fmt::Display for CustomFieldType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
/// A tag that can be applied to media items.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tag {
@ -210,6 +227,21 @@ pub enum CollectionKind {
Virtual,
}
impl CollectionKind {
pub fn as_str(&self) -> &'static str {
match self {
Self::Manual => "manual",
Self::Virtual => "virtual",
}
}
}
impl std::fmt::Display for CollectionKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
/// A member of a collection with position tracking.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CollectionMember {