#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "me.linkna.lastfm",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Lastfm<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub artist_mb_id: Option<S>,
pub artist_names: Vec<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cover_art_url: Option<S>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub origin_url: Option<UriValue<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub played_time: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub release_mb_id: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub release_name: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub track_mb_id: Option<S>,
pub track_name: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LastfmGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Lastfm<S>,
}
impl<S: BosStr> Lastfm<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, LastfmRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LastfmRecord;
impl XrpcResp for LastfmRecord {
const NSID: &'static str = "me.linkna.lastfm";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = LastfmGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<LastfmGetRecordOutput<S>> for Lastfm<S> {
fn from(output: LastfmGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Lastfm<S> {
const NSID: &'static str = "me.linkna.lastfm";
type Record = LastfmRecord;
}
impl Collection for LastfmRecord {
const NSID: &'static str = "me.linkna.lastfm";
type Record = LastfmRecord;
}
impl<S: BosStr> LexiconSchema for Lastfm<S> {
fn nsid() -> &'static str {
"me.linkna.lastfm"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_me_linkna_lastfm()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod lastfm_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type TrackName;
type ArtistNames;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type TrackName = Unset;
type ArtistNames = Unset;
type CreatedAt = Unset;
}
pub struct SetTrackName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTrackName<St> {}
impl<St: State> State for SetTrackName<St> {
type TrackName = Set<members::track_name>;
type ArtistNames = St::ArtistNames;
type CreatedAt = St::CreatedAt;
}
pub struct SetArtistNames<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetArtistNames<St> {}
impl<St: State> State for SetArtistNames<St> {
type TrackName = St::TrackName;
type ArtistNames = Set<members::artist_names>;
type CreatedAt = St::CreatedAt;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type TrackName = St::TrackName;
type ArtistNames = St::ArtistNames;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct track_name(());
pub struct artist_names(());
pub struct created_at(());
}
}
pub struct LastfmBuilder<S: BosStr, St: lastfm_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<Vec<S>>,
Option<S>,
Option<Datetime>,
Option<UriValue<S>>,
Option<Datetime>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Lastfm<S> {
pub fn new() -> LastfmBuilder<S, lastfm_state::Empty> {
LastfmBuilder::new()
}
}
impl<S: BosStr> LastfmBuilder<S, lastfm_state::Empty> {
pub fn new() -> Self {
LastfmBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: lastfm_state::State> LastfmBuilder<S, St> {
pub fn artist_mb_id(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_artist_mb_id(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> LastfmBuilder<S, St>
where
St: lastfm_state::State,
St::ArtistNames: lastfm_state::IsUnset,
{
pub fn artist_names(
mut self,
value: impl Into<Vec<S>>,
) -> LastfmBuilder<S, lastfm_state::SetArtistNames<St>> {
self._fields.1 = Option::Some(value.into());
LastfmBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: lastfm_state::State> LastfmBuilder<S, St> {
pub fn cover_art_url(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_cover_art_url(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> LastfmBuilder<S, St>
where
St: lastfm_state::State,
St::CreatedAt: lastfm_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> LastfmBuilder<S, lastfm_state::SetCreatedAt<St>> {
self._fields.3 = Option::Some(value.into());
LastfmBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: lastfm_state::State> LastfmBuilder<S, St> {
pub fn origin_url(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_origin_url(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: lastfm_state::State> LastfmBuilder<S, St> {
pub fn played_time(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_played_time(mut self, value: Option<Datetime>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: lastfm_state::State> LastfmBuilder<S, St> {
pub fn release_mb_id(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_release_mb_id(mut self, value: Option<S>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: lastfm_state::State> LastfmBuilder<S, St> {
pub fn release_name(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_release_name(mut self, value: Option<S>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: lastfm_state::State> LastfmBuilder<S, St> {
pub fn track_mb_id(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_track_mb_id(mut self, value: Option<S>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> LastfmBuilder<S, St>
where
St: lastfm_state::State,
St::TrackName: lastfm_state::IsUnset,
{
pub fn track_name(
mut self,
value: impl Into<S>,
) -> LastfmBuilder<S, lastfm_state::SetTrackName<St>> {
self._fields.9 = Option::Some(value.into());
LastfmBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LastfmBuilder<S, St>
where
St: lastfm_state::State,
St::TrackName: lastfm_state::IsSet,
St::ArtistNames: lastfm_state::IsSet,
St::CreatedAt: lastfm_state::IsSet,
{
pub fn build(self) -> Lastfm<S> {
Lastfm {
artist_mb_id: self._fields.0,
artist_names: self._fields.1.unwrap(),
cover_art_url: self._fields.2,
created_at: self._fields.3.unwrap(),
origin_url: self._fields.4,
played_time: self._fields.5,
release_mb_id: self._fields.6,
release_name: self._fields.7,
track_mb_id: self._fields.8,
track_name: self._fields.9.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Lastfm<S> {
Lastfm {
artist_mb_id: self._fields.0,
artist_names: self._fields.1.unwrap(),
cover_art_url: self._fields.2,
created_at: self._fields.3.unwrap(),
origin_url: self._fields.4,
played_time: self._fields.5,
release_mb_id: self._fields.6,
release_name: self._fields.7,
track_mb_id: self._fields.8,
track_name: self._fields.9.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_me_linkna_lastfm() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("me.linkna.lastfm"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A Last.fm scrobble play record written by Linkname.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("trackName"),
SmolStr::new_static("artistNames"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("artistMbId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("MusicBrainz ID for the artist."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artistNames"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static("Artist name(s).")),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("coverArtUrl"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URL to the album cover art."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When this record was created."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("originUrl"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URL to the track on Last.fm."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("playedTime"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When the track was played on Last.fm."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("releaseMbId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("MusicBrainz ID for the release/album."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("releaseName"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Album/release name."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("trackMbId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("MusicBrainz ID for the track."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("trackName"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Track/song name.")),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}