mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
database: Remove serde
This commit is contained in:
parent
32ecf2d4bd
commit
678367ec1a
8 changed files with 12 additions and 71 deletions
|
|
@ -8,8 +8,6 @@ diesel = { version = "1.4.5", features = ["sqlite"] }
|
|||
diesel_migrations = "1.4.0"
|
||||
log = "0.4.14"
|
||||
rand = "0.7.3"
|
||||
serde = { version = "1.0.117", features = ["derive"] }
|
||||
serde_json = "1.0.59"
|
||||
thiserror = "1.0.23"
|
||||
tokio = { version = "1.4.0", features = ["sync"] }
|
||||
uuid = { version = "0.8", features = ["v4"] }
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ use super::schema::ensembles;
|
|||
use super::{Database, Result};
|
||||
use diesel::prelude::*;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An ensemble that takes part in recordings.
|
||||
#[derive(Serialize, Deserialize, Insertable, Queryable, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(Insertable, Queryable, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct Ensemble {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ use super::schema::instruments;
|
|||
use super::{Database, Result};
|
||||
use diesel::prelude::*;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An instrument or any other possible role within a recording.
|
||||
#[derive(Serialize, Deserialize, Insertable, Queryable, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(Insertable, Queryable, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct Instrument {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@ use super::schema::{ensembles, mediums, performances, persons, recordings, track
|
|||
use super::{Database, Error, Recording, Result};
|
||||
use diesel::prelude::*;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Representation of someting like a physical audio disc or a folder with
|
||||
/// audio files (i.e. a collection of tracks for one or more recordings).
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct Medium {
|
||||
/// An unique ID for the medium.
|
||||
pub id: String,
|
||||
|
|
@ -24,8 +22,7 @@ pub struct Medium {
|
|||
}
|
||||
|
||||
/// A track on a medium.
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct Track {
|
||||
/// The recording on this track.
|
||||
pub recording: Recording,
|
||||
|
|
@ -38,9 +35,7 @@ pub struct Track {
|
|||
/// the metadata with the audio data from the source when importing.
|
||||
pub source_index: usize,
|
||||
|
||||
/// The path to the audio file containing this track. This will not be
|
||||
/// included when communicating with the server.
|
||||
#[serde(skip)]
|
||||
/// The path to the audio file containing this track.
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ use super::schema::persons;
|
|||
use super::{Database, Result};
|
||||
use diesel::prelude::*;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A person that is a composer, an interpret or both.
|
||||
#[derive(Serialize, Deserialize, Insertable, Queryable, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(Insertable, Queryable, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct Person {
|
||||
pub id: String,
|
||||
pub first_name: String,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@ use super::schema::{ensembles, performances, persons, recordings};
|
|||
use super::{Database, Ensemble, Error, Instrument, Person, Result, Work};
|
||||
use diesel::prelude::*;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A specific recording of a work.
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct Recording {
|
||||
pub id: String,
|
||||
pub work: Work,
|
||||
|
|
@ -40,8 +38,7 @@ impl Recording {
|
|||
}
|
||||
|
||||
/// How a person or ensemble was involved in a recording.
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct Performance {
|
||||
pub performer: PersonOrEnsemble,
|
||||
pub role: Option<Instrument>,
|
||||
|
|
@ -62,7 +59,7 @@ impl Performance {
|
|||
}
|
||||
|
||||
/// Either a person or an ensemble.
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Clone, Debug)]
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
|
||||
pub enum PersonOrEnsemble {
|
||||
Person(Person),
|
||||
Ensemble(Ensemble),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use super::{Database, Error, Instrument, Person, Result};
|
|||
use diesel::prelude::*;
|
||||
use diesel::{Insertable, Queryable};
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Table row data for a work.
|
||||
#[derive(Insertable, Queryable, Debug, Clone)]
|
||||
|
|
@ -54,23 +53,20 @@ struct WorkSectionRow {
|
|||
pub before_index: i64,
|
||||
}
|
||||
/// A concrete work part that can be recorded.
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct WorkPart {
|
||||
pub title: String,
|
||||
}
|
||||
|
||||
/// A heading between work parts.
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct WorkSection {
|
||||
pub title: String,
|
||||
pub before_index: usize,
|
||||
}
|
||||
|
||||
/// A specific work by a composer.
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
|
||||
pub struct Work {
|
||||
pub id: String,
|
||||
pub title: String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue