| Crates.io | moosicbox_music_models |
| lib.rs | moosicbox_music_models |
| version | 0.1.4 |
| created_at | 2025-05-07 13:18:58.184649+00 |
| updated_at | 2025-07-21 19:20:40.11824+00 |
| description | MoosicBox Music models package |
| homepage | |
| repository | https://github.com/MoosicBox/MoosicBox |
| max_upload_size | |
| id | 1663825 |
| size | 139,256 |
Core data models for music metadata, sources, and API integration.
The MoosicBox Music Models package provides:
Add this to your Cargo.toml:
[dependencies]
moosicbox_music_models = { path = "../music/models" }
# Enable specific features
moosicbox_music_models = {
path = "../music/models",
features = ["api", "db", "flac", "mp3", "aac", "opus"]
}
use moosicbox_music_models::ApiSource;
// Register a new API source
let tidal_source = ApiSource::register("tidal", "Tidal");
let qobuz_source = ApiSource::register("qobuz", "Qobuz");
// Use library source
let library_source = ApiSource::library();
// Check if source is library
if source.is_library() {
println!("This is a local library source");
}
use moosicbox_music_models::{Track, AudioFormat, TrackApiSource};
let track = Track {
id: 1.into(),
number: 1,
title: "Bohemian Rhapsody".to_string(),
duration: 355.0,
album: "A Night at the Opera".to_string(),
album_id: 1.into(),
artist: "Queen".to_string(),
artist_id: 1.into(),
format: Some(AudioFormat::Flac),
bit_depth: Some(24),
sample_rate: Some(96000),
track_source: TrackApiSource::Local,
api_source: ApiSource::library(),
..Default::default()
};
use moosicbox_music_models::{ApiSources, ApiSource};
let mut sources = ApiSources::default();
sources.add_source(ApiSource::library(), 123.into());
sources.add_source(tidal_source, 456.into());
sources.add_source(qobuz_source, 789.into());
// Get ID for specific source
if let Some(tidal_id) = sources.get(&tidal_source) {
println!("Tidal ID: {}", tidal_id);
}
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
This is the short help; for all options use 'flac --help'; for more explanation and examples please consult the manual. This manual is often distributed alongside the program as a man page or an HTML file. It can also be found online at https://xiph.org/flac/documentation_tools_flac.html
To encode: flac [-#] [INPUTFILE [...]]
-# is -0 (fastest compression) to -8 (highest compression); -5 is the default
To decode: flac -d [INPUTFILE [...]]
To test: flac -t [INPUTFILE [...]] feature)
use moosicbox_music_models::from_extension_to_audio_format;
let format = from_extension_to_audio_format("flac");
assert_eq!(format, Some(AudioFormat::Flac));
use moosicbox_music_models::{AlbumVersionQuality, AudioFormat};
let hires_version = AlbumVersionQuality {
format: Some(AudioFormat::Flac),
bit_depth: Some(24),
sample_rate: Some(192000),
channels: Some(2),
source: TrackApiSource::Local,
};
let cd_version = AlbumVersionQuality {
format: Some(AudioFormat::Flac),
bit_depth: Some(16),
sample_rate: Some(44100),
channels: Some(2),
source: TrackApiSource::Local,
};
api: Enable API-compatible model structuresdb: Enable database-compatible model structuresflac: Enable FLAC audio format supportmp3: Enable MP3 audio format supportaac: Enable AAC audio format supportopus: Enable Opus audio format supportThis package is the foundation for: