pub mod create_scrobble;
pub mod get_scrobble;
pub mod get_scrobbles;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::blob::BlobRef;
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::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};
use crate::app_rocksky::artist::ArtistMbid;
use crate::app_rocksky::artist::ArtistViewBasic;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Scrobble<'a> {
#[serde(borrow)]
pub album: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub album_art: Option<BlobRef<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub album_art_url: Option<UriValue<'a>>,
#[serde(borrow)]
pub album_artist: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub apple_music_link: Option<UriValue<'a>>,
#[serde(borrow)]
pub artist: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub artists: Option<Vec<ArtistMbid<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub composer: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub copyright_message: Option<CowStr<'a>>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub disc_number: Option<i64>,
pub duration: i64,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub genre: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub label: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub lyrics: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub mbid: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub release_date: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub spotify_link: Option<UriValue<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub tags: Option<Vec<CowStr<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub tidal_link: Option<UriValue<'a>>,
#[serde(borrow)]
pub title: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub track_number: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub wiki: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub year: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub youtube_link: Option<UriValue<'a>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ScrobbleGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Scrobble<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ScrobbleViewBasic<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub album: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub album_uri: Option<AtUri<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub artist: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub artist_uri: Option<AtUri<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cover: Option<UriValue<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub date: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub liked: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub likes_count: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub sha256: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub title: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub uri: Option<UriValue<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub user: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub user_avatar: Option<UriValue<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub user_display_name: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ScrobbleViewDetailed<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub album: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub album_uri: Option<AtUri<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub artist: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub artist_uri: Option<AtUri<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub artists: Option<Vec<ArtistViewBasic<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cover: Option<UriValue<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub date: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub listeners: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub scrobbles: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub sha256: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub title: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub uri: Option<UriValue<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub user: Option<CowStr<'a>>,
}
impl<'a> Scrobble<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, ScrobbleRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ScrobbleRecord;
impl XrpcResp for ScrobbleRecord {
const NSID: &'static str = "app.rocksky.scrobble";
const ENCODING: &'static str = "application/json";
type Output<'de> = ScrobbleGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<ScrobbleGetRecordOutput<'_>> for Scrobble<'_> {
fn from(output: ScrobbleGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Scrobble<'_> {
const NSID: &'static str = "app.rocksky.scrobble";
type Record = ScrobbleRecord;
}
impl Collection for ScrobbleRecord {
const NSID: &'static str = "app.rocksky.scrobble";
type Record = ScrobbleRecord;
}
impl<'a> LexiconSchema for Scrobble<'a> {
fn nsid() -> &'static str {
"app.rocksky.scrobble"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_rocksky_scrobble()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.album;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("album"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.album;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("album"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.album_art {
{
let size = value.blob().size;
if size > 2000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("album_art"),
max: 2000000usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.album_art {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg"];
let matched = accepted
.iter()
.any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix)
&& mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("album_art"),
accepted: vec![
"image/png".to_string(), "image/jpeg".to_string()
],
actual: mime.to_string(),
});
}
}
}
{
let value = &self.album_artist;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("album_artist"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.album_artist;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("album_artist"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.artist;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("artist"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.artist;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("artist"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.composer {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("composer"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.copyright_message {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("copyright_message"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.disc_number {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("disc_number"),
min: 1i64,
actual: *value,
});
}
}
{
let value = &self.duration;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("duration"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.genre {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("genre"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.label {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("label"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.lyrics {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("lyrics"),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("title"),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("title"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.track_number {
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("track_number"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.wiki {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("wiki"),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for ScrobbleViewBasic<'a> {
fn nsid() -> &'static str {
"app.rocksky.scrobble.defs"
}
fn def_name() -> &'static str {
"scrobbleViewBasic"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_rocksky_scrobble_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for ScrobbleViewDetailed<'a> {
fn nsid() -> &'static str {
"app.rocksky.scrobble.defs"
}
fn def_name() -> &'static str {
"scrobbleViewDetailed"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_rocksky_scrobble_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod scrobble_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 Album;
type Title;
type Duration;
type AlbumArtist;
type Artist;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Album = Unset;
type Title = Unset;
type Duration = Unset;
type AlbumArtist = Unset;
type Artist = Unset;
type CreatedAt = Unset;
}
pub struct SetAlbum<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAlbum<S> {}
impl<S: State> State for SetAlbum<S> {
type Album = Set<members::album>;
type Title = S::Title;
type Duration = S::Duration;
type AlbumArtist = S::AlbumArtist;
type Artist = S::Artist;
type CreatedAt = S::CreatedAt;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type Album = S::Album;
type Title = Set<members::title>;
type Duration = S::Duration;
type AlbumArtist = S::AlbumArtist;
type Artist = S::Artist;
type CreatedAt = S::CreatedAt;
}
pub struct SetDuration<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDuration<S> {}
impl<S: State> State for SetDuration<S> {
type Album = S::Album;
type Title = S::Title;
type Duration = Set<members::duration>;
type AlbumArtist = S::AlbumArtist;
type Artist = S::Artist;
type CreatedAt = S::CreatedAt;
}
pub struct SetAlbumArtist<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAlbumArtist<S> {}
impl<S: State> State for SetAlbumArtist<S> {
type Album = S::Album;
type Title = S::Title;
type Duration = S::Duration;
type AlbumArtist = Set<members::album_artist>;
type Artist = S::Artist;
type CreatedAt = S::CreatedAt;
}
pub struct SetArtist<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetArtist<S> {}
impl<S: State> State for SetArtist<S> {
type Album = S::Album;
type Title = S::Title;
type Duration = S::Duration;
type AlbumArtist = S::AlbumArtist;
type Artist = Set<members::artist>;
type CreatedAt = S::CreatedAt;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Album = S::Album;
type Title = S::Title;
type Duration = S::Duration;
type AlbumArtist = S::AlbumArtist;
type Artist = S::Artist;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct album(());
pub struct title(());
pub struct duration(());
pub struct album_artist(());
pub struct artist(());
pub struct created_at(());
}
}
pub struct ScrobbleBuilder<'a, S: scrobble_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<BlobRef<'a>>,
Option<UriValue<'a>>,
Option<CowStr<'a>>,
Option<UriValue<'a>>,
Option<CowStr<'a>>,
Option<Vec<ArtistMbid<'a>>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<i64>,
Option<i64>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<UriValue<'a>>,
Option<Vec<CowStr<'a>>>,
Option<UriValue<'a>>,
Option<CowStr<'a>>,
Option<i64>,
Option<CowStr<'a>>,
Option<i64>,
Option<UriValue<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Scrobble<'a> {
pub fn new() -> ScrobbleBuilder<'a, scrobble_state::Empty> {
ScrobbleBuilder::new()
}
}
impl<'a> ScrobbleBuilder<'a, scrobble_state::Empty> {
pub fn new() -> Self {
ScrobbleBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ScrobbleBuilder<'a, S>
where
S: scrobble_state::State,
S::Album: scrobble_state::IsUnset,
{
pub fn album(
mut self,
value: impl Into<CowStr<'a>>,
) -> ScrobbleBuilder<'a, scrobble_state::SetAlbum<S>> {
self._fields.0 = Option::Some(value.into());
ScrobbleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn album_art(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_album_art(mut self, value: Option<BlobRef<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn album_art_url(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_album_art_url(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> ScrobbleBuilder<'a, S>
where
S: scrobble_state::State,
S::AlbumArtist: scrobble_state::IsUnset,
{
pub fn album_artist(
mut self,
value: impl Into<CowStr<'a>>,
) -> ScrobbleBuilder<'a, scrobble_state::SetAlbumArtist<S>> {
self._fields.3 = Option::Some(value.into());
ScrobbleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn apple_music_link(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_apple_music_link(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> ScrobbleBuilder<'a, S>
where
S: scrobble_state::State,
S::Artist: scrobble_state::IsUnset,
{
pub fn artist(
mut self,
value: impl Into<CowStr<'a>>,
) -> ScrobbleBuilder<'a, scrobble_state::SetArtist<S>> {
self._fields.5 = Option::Some(value.into());
ScrobbleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn artists(mut self, value: impl Into<Option<Vec<ArtistMbid<'a>>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_artists(mut self, value: Option<Vec<ArtistMbid<'a>>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn composer(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_composer(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn copyright_message(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_copyright_message(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.8 = value;
self
}
}
impl<'a, S> ScrobbleBuilder<'a, S>
where
S: scrobble_state::State,
S::CreatedAt: scrobble_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> ScrobbleBuilder<'a, scrobble_state::SetCreatedAt<S>> {
self._fields.9 = Option::Some(value.into());
ScrobbleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn disc_number(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_disc_number(mut self, value: Option<i64>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S> ScrobbleBuilder<'a, S>
where
S: scrobble_state::State,
S::Duration: scrobble_state::IsUnset,
{
pub fn duration(
mut self,
value: impl Into<i64>,
) -> ScrobbleBuilder<'a, scrobble_state::SetDuration<S>> {
self._fields.11 = Option::Some(value.into());
ScrobbleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn genre(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.12 = value.into();
self
}
pub fn maybe_genre(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.12 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn label(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.13 = value.into();
self
}
pub fn maybe_label(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.13 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn lyrics(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.14 = value.into();
self
}
pub fn maybe_lyrics(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.14 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn mbid(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.15 = value.into();
self
}
pub fn maybe_mbid(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.15 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn release_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.16 = value.into();
self
}
pub fn maybe_release_date(mut self, value: Option<Datetime>) -> Self {
self._fields.16 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn spotify_link(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.17 = value.into();
self
}
pub fn maybe_spotify_link(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.17 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn tags(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
self._fields.18 = value.into();
self
}
pub fn maybe_tags(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
self._fields.18 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn tidal_link(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.19 = value.into();
self
}
pub fn maybe_tidal_link(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.19 = value;
self
}
}
impl<'a, S> ScrobbleBuilder<'a, S>
where
S: scrobble_state::State,
S::Title: scrobble_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> ScrobbleBuilder<'a, scrobble_state::SetTitle<S>> {
self._fields.20 = Option::Some(value.into());
ScrobbleBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn track_number(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.21 = value.into();
self
}
pub fn maybe_track_number(mut self, value: Option<i64>) -> Self {
self._fields.21 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn wiki(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.22 = value.into();
self
}
pub fn maybe_wiki(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.22 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn year(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.23 = value.into();
self
}
pub fn maybe_year(mut self, value: Option<i64>) -> Self {
self._fields.23 = value;
self
}
}
impl<'a, S: scrobble_state::State> ScrobbleBuilder<'a, S> {
pub fn youtube_link(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.24 = value.into();
self
}
pub fn maybe_youtube_link(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.24 = value;
self
}
}
impl<'a, S> ScrobbleBuilder<'a, S>
where
S: scrobble_state::State,
S::Album: scrobble_state::IsSet,
S::Title: scrobble_state::IsSet,
S::Duration: scrobble_state::IsSet,
S::AlbumArtist: scrobble_state::IsSet,
S::Artist: scrobble_state::IsSet,
S::CreatedAt: scrobble_state::IsSet,
{
pub fn build(self) -> Scrobble<'a> {
Scrobble {
album: self._fields.0.unwrap(),
album_art: self._fields.1,
album_art_url: self._fields.2,
album_artist: self._fields.3.unwrap(),
apple_music_link: self._fields.4,
artist: self._fields.5.unwrap(),
artists: self._fields.6,
composer: self._fields.7,
copyright_message: self._fields.8,
created_at: self._fields.9.unwrap(),
disc_number: self._fields.10,
duration: self._fields.11.unwrap(),
genre: self._fields.12,
label: self._fields.13,
lyrics: self._fields.14,
mbid: self._fields.15,
release_date: self._fields.16,
spotify_link: self._fields.17,
tags: self._fields.18,
tidal_link: self._fields.19,
title: self._fields.20.unwrap(),
track_number: self._fields.21,
wiki: self._fields.22,
year: self._fields.23,
youtube_link: self._fields.24,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Scrobble<'a> {
Scrobble {
album: self._fields.0.unwrap(),
album_art: self._fields.1,
album_art_url: self._fields.2,
album_artist: self._fields.3.unwrap(),
apple_music_link: self._fields.4,
artist: self._fields.5.unwrap(),
artists: self._fields.6,
composer: self._fields.7,
copyright_message: self._fields.8,
created_at: self._fields.9.unwrap(),
disc_number: self._fields.10,
duration: self._fields.11.unwrap(),
genre: self._fields.12,
label: self._fields.13,
lyrics: self._fields.14,
mbid: self._fields.15,
release_date: self._fields.16,
spotify_link: self._fields.17,
tags: self._fields.18,
tidal_link: self._fields.19,
title: self._fields.20.unwrap(),
track_number: self._fields.21,
wiki: self._fields.22,
year: self._fields.23,
youtube_link: self._fields.24,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_rocksky_scrobble() -> 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("app.rocksky.scrobble"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static("A declaration of a scrobble."),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("title"), SmolStr::new_static("artist"),
SmolStr::new_static("album"),
SmolStr::new_static("albumArtist"),
SmolStr::new_static("duration"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("album"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The album of the song."),
),
min_length: Some(1usize),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("albumArt"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("albumArtUrl"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The URL of the album art of the song."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("albumArtist"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The album artist of the song."),
),
min_length: Some(1usize),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("appleMusicLink"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The Apple Music link of the song."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artist"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The artist of the song."),
),
min_length: Some(1usize),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artists"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"The artists of the song with MusicBrainz IDs.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static(
"app.rocksky.artist.defs#artistMbid",
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("composer"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The composer of the song."),
),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("copyrightMessage"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The copyright message of the song."),
),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The date when the song was created."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("discNumber"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("duration"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("genre"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The genre of the song."),
),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("label"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The label of the song."),
),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lyrics"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The lyrics of the song."),
),
max_length: Some(10000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mbid"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The MusicBrainz ID of the song."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("releaseDate"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The release date of the song."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("spotifyLink"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The Spotify link of the song."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tags"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("The tags of the song."),
),
items: LexArrayItem::String(LexString {
min_length: Some(1usize),
max_length: Some(256usize),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tidalLink"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The Tidal link of the song."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The title of the song."),
),
min_length: Some(1usize),
max_length: Some(512usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("trackNumber"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("wiki"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Informations about the song"),
),
max_length: Some(10000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("year"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("youtubeLink"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The YouTube link of the song."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
fn lexicon_doc_app_rocksky_scrobble_defs() -> 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("app.rocksky.scrobble.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("scrobbleViewBasic"),
LexUserType::Object(LexObject {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("album"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The album of the song."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("albumUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The URI of the album."),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artist"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The artist of the song."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artistUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The URI of the artist."),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cover"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The album art URL of the song."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("date"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The timestamp when the scrobble was created.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The unique identifier of the scrobble."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("liked"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("likesCount"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sha256"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The SHA256 hash of the scrobble data."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The title of the scrobble."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The URI of the scrobble."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("user"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The handle of the user who created the scrobble.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("userAvatar"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The avatar URL of the user who created the scrobble.",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("userDisplayName"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The display name of the user who created the scrobble.",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scrobbleViewDetailed"),
LexUserType::Object(LexObject {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("album"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The album of the song."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("albumUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The URI of the album."),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artist"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The artist of the song."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artistUri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The URI of the artist."),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("artists"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static(
"app.rocksky.artist.defs#artistViewBasic",
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cover"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The album art URL of the song."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("date"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The timestamp when the scrobble was created.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The unique identifier of the scrobble."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("listeners"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scrobbles"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sha256"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The SHA256 hash of the scrobble data."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The title of the scrobble."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The URI of the scrobble."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("user"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The handle of the user who created the scrobble.",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}