Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions crates/workshop-rs/src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use serde::{Deserialize, Deserializer, Serialize};

use crate::signatures::ExpectedDomain;

Expand All @@ -46,6 +46,16 @@ impl Locale {
}
}

impl<'de> Deserialize<'de> for Locale {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value = String::deserialize(deserializer)?;
Ok(Self::new(&value))
}
}

impl std::fmt::Display for Locale {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
Expand Down Expand Up @@ -156,7 +166,7 @@ pub struct Provenance {

/// Per-locale mapping coverage: how many canonical entries (builtins and
/// enum members) carry a mapping for the locale out of the declared total.
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct LocaleCoverage {
pub locale: Locale,
/// Canonical entries with a declared mapping in this locale.
Expand All @@ -170,7 +180,7 @@ pub struct LocaleCoverage {
/// dataset version plus content digest, locale coverage, and target evidence
/// — plus the data provenance record. Serialized with the ADR's kebab-case
/// identity names.
#[derive(Debug, Clone, PartialEq, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct CatalogIdentity {
/// The `workshop-rs` package version (semver); bumped by code changes.
Expand Down
Loading