Skip to main content

allfeat_midds_v2/
lib.rs

1//! # MIDDS v2 - Music Industry Data Description Standard
2//!
3//! This crate provides comprehensive data structures for representing music industry metadata
4//! in a blockchain-compatible format. MIDDS v2 includes structures for musical works, tracks,
5//! releases, and associated metadata.
6//!
7//! ## Core Types
8//!
9//! - [`MusicalWork`](musical_work::MusicalWork) - Represents compositions and songwriting metadata
10//! - [`Recording`](recording::Recording) - Represents recordings and performance metadata
11//! - [`Release`](release::Release) - Represents albums, EPs, singles and distribution metadata
12//!
13//! ## Key Features
14//!
15//! - **Substrate Compatible**: All types implement necessary traits for blockchain storage
16//! - **Validation-Free**: No runtime validation, designed for application-level validation
17//! - **Industry Standards**: Uses ISWC, ISRC, EAN/UPC and other industry identifiers
18//! - **Comprehensive Metadata**: Supports extensive metadata for all music industry use cases
19//!
20//! ## Example Usage
21//!
22//! ```rust
23//! use allfeat_midds_v2::{
24//!     musical_work::{MusicalWork, Creator, CreatorRole},
25//!     shared::{PartyId, Key, Language},
26//! };
27//!
28//! // Create a musical work
29//! let work = MusicalWork {
30//!     iswc: b"T1234567890".to_vec().try_into().unwrap(),
31//!     title: b"Example Song".to_vec().try_into().unwrap(),
32//!     creation_year: Some(2024),
33//!     instrumental: Some(false),
34//!     language: Some(Language::English),
35//!     bpm: Some(120),
36//!     key: Some(Key::C),
37//!     work_type: None,
38//!     creators: vec![Creator {
39//!         id: PartyId::Ipi(123456789),
40//!         role: CreatorRole::Composer,
41//!     }].try_into().unwrap(),
42//!     classical_info: None,
43//! };
44//! ```
45
46#![cfg_attr(not(feature = "std"), no_std)]
47
48use frame_support::{traits::ConstU32, BoundedVec};
49
50/// Unique identifier type used across all MIDDS entities.
51///
52/// This type represents a unique 64-bit identifier that can be used to reference
53/// musical works, tracks, releases, or parties within the MIDDS ecosystem.
54///
55/// # Example
56///
57/// ```rust
58/// use allfeat_midds_v2::MiddsId;
59///
60/// let work_id: MiddsId = 12345;
61/// let recording_id: MiddsId = 67890;
62/// ```
63pub type MiddsId = u64;
64
65/// Bounded string type used throughout MIDDS for text fields.
66///
67/// This type provides a space-efficient, bounded string representation that is compatible
68/// with Substrate's storage requirements. The generic parameter `S` defines the maximum
69/// length in bytes.
70///
71/// # Example
72///
73/// ```rust
74/// use allfeat_midds_v2::MiddsString;
75///
76/// // Create a bounded string with max 256 bytes
77/// let title: MiddsString<256> = b"My Song Title".to_vec().try_into().unwrap();
78/// assert_eq!(title.len(), 13);
79/// ```
80pub type MiddsString<const S: u32> = BoundedVec<u8, ConstU32<S>>;
81
82/// Bounded vector type used throughout MIDDS for collections.
83///
84/// This type provides a space-efficient, bounded collection that is compatible
85/// with Substrate's storage requirements. The generic parameter `S` defines the maximum
86/// number of elements.
87///
88/// # Example
89///
90/// ```rust
91/// use allfeat_midds_v2::{MiddsVec, MiddsId};
92///
93/// // Create a bounded vector of recording IDs with max 10 elements
94/// let recording_ids: MiddsVec<MiddsId, 10> = vec![1, 2, 3].try_into().unwrap();
95/// assert_eq!(recording_ids.len(), 3);
96/// ```
97pub type MiddsVec<T, const S: u32> = BoundedVec<T, ConstU32<S>>;
98
99pub mod musical_work;
100
101pub mod release;
102
103pub mod recording;
104
105/// Shared utility types and common enumerations.
106///
107/// Contains common types used across all MIDDS structures including dates,
108/// countries, languages, and musical keys.
109pub mod shared;
110
111#[cfg(feature = "runtime-benchmarks")]
112pub mod benchmarking;