spoolframe-types 0.17.1

Spoolframe's client-facing types: the media model and its identifiers.
Documentation
//! The types UniFFI passes as another type (feature `uniffi`): the IDs and
//! the calendar date as the strings they are on the wire, so a foreign
//! language holds the same text the protocol sends and parses nothing.

use crate::{ArtworkId, CalendarDate, LibraryId, Marker, Markers, MediaId, PersonId};

uniffi::custom_type!(MediaId, String, {
    lower: |id| id.to_string(),
    try_lift: |text| Ok(text.parse()?),
});

uniffi::custom_type!(LibraryId, String, {
    lower: |id| id.to_string(),
    try_lift: |text| Ok(text.parse()?),
});

uniffi::custom_type!(ArtworkId, String, {
    lower: |id| id.to_string(),
    try_lift: |text| Ok(text.parse()?),
});

uniffi::custom_type!(PersonId, String, {
    lower: |id| id.to_string(),
    try_lift: |text| Ok(text.parse()?),
});

// A plain list of markers to Swift and Kotlin.
uniffi::custom_type!(Markers, Vec<Marker>, {
    lower: |markers| markers.into_vec(),
    try_lift: |markers| Ok(Markers::from(markers)),
});

// `YYYY-MM-DD`.
uniffi::custom_type!(CalendarDate, String, {
    lower: |date| date.to_string(),
    try_lift: |text| Ok(text.parse()?),
});