use crate::{
shared::PartyId,
shared::{Key, Language},
MiddsId, MiddsString, MiddsVec,
};
use parity_scale_codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use ts_rs::TS;
#[cfg(feature = "std")]
const TS_DIR: &str = "musical_work/";
pub type Iswc = MiddsString<11>;
#[derive(
Debug, Clone, PartialEq, Eq, Encode, Decode, DecodeWithMemTracking, TypeInfo, MaxEncodedLen,
)]
#[cfg_attr(feature = "std", derive(TS), ts(export, export_to = TS_DIR, optional_fields, rename_all = "camelCase"))]
pub struct MusicalWork {
#[cfg_attr(feature = "std", ts(as = "String"))]
pub iswc: Iswc,
#[cfg_attr(feature = "std", ts(as = "String"))]
pub title: MiddsString<256>,
pub creation_year: Option<u16>,
pub instrumental: Option<bool>,
pub language: Option<Language>,
pub bpm: Option<u16>,
pub key: Option<Key>,
pub work_type: Option<MusicalWorkType>,
#[cfg_attr(feature = "std", ts(as = "Vec<Creator>"))]
pub creators: MiddsVec<Creator, 256>,
pub classical_info: Option<ClassicalInfo>,
}
#[derive(
Clone, Debug, PartialEq, Eq, Encode, Decode, MaxEncodedLen, DecodeWithMemTracking, TypeInfo,
)]
#[cfg_attr(feature = "std", derive(TS), ts(export, export_to = TS_DIR))]
pub enum MusicalWorkType {
Original,
#[cfg_attr(feature = "std", ts(as = "Vec<MiddsId>"))]
Medley(MiddsVec<MiddsId, 512>),
#[cfg_attr(feature = "std", ts(as = "Vec<MiddsId>"))]
Mashup(MiddsVec<MiddsId, 512>),
Adaptation(MiddsId),
}
#[derive(
Clone, Debug, PartialEq, Eq, Encode, Decode, MaxEncodedLen, DecodeWithMemTracking, TypeInfo,
)]
#[cfg_attr(feature = "std", derive(TS), ts(export, export_to = TS_DIR))]
pub struct Creator {
pub id: PartyId,
pub role: CreatorRole,
}
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Encode,
Decode,
MaxEncodedLen,
DecodeWithMemTracking,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(TS), ts(export, export_to = TS_DIR))]
pub enum CreatorRole {
Author,
Composer,
Arranger,
Adapter,
Publisher,
}
#[derive(
Clone, Debug, PartialEq, Eq, Encode, Decode, MaxEncodedLen, DecodeWithMemTracking, TypeInfo,
)]
#[cfg_attr(feature = "std", derive(TS), ts(export, export_to = TS_DIR, optional_fields, rename_all = "camelCase"))]
pub struct ClassicalInfo {
#[cfg_attr(feature = "std", ts(as = "Option<String>"))]
pub opus: Option<MiddsString<256>>,
#[cfg_attr(feature = "std", ts(as = "Option<String>"))]
pub catalog_number: Option<MiddsString<256>>,
pub number_of_voices: Option<u16>,
}