Skip to content

Commit

Permalink
API changes for better ergonomics
Browse files Browse the repository at this point in the history
  • Loading branch information
rbermani committed Nov 17, 2023
1 parent 67ae5c4 commit b0fd664
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["Robert Bermani <[email protected]>"]
description = "A Rust library for serializing and deserializing MusicXML files to an intermediate representation."
homepage = "https://github.com/rbermani/muxml-rust"
name = "muxml"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
readme = "README.md"
keywords = ["musicxml", "serialization", "deserialization"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This crate is available on [crates.io](https://crates.io/crates/muxml). To use i

```toml
[dependencies]
muxml = "0.1.1"
muxml = "0.1.2"
```

## Usage
Expand Down
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright (c) 2022-2023 Robert Bermani - All Rights Reserved
pub mod error;
pub mod muxml_types;

mod ser;
#[allow(dead_code)]
mod score;
pub mod ser;
pub mod score;

#[cfg(test)]
mod test;
47 changes: 35 additions & 12 deletions src/muxml_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,27 +240,50 @@ pub struct GraceElement {
#[serde(rename_all = "kebab-case")]
pub struct NoteElement {
#[serde(skip_serializing_if = "Option::is_none")]
chord: Option<ChordElement>,
pub chord: Option<ChordElement>,
#[serde(skip_serializing_if = "Option::is_none")]
grace: Option<GraceElement>,
pub grace: Option<GraceElement>,
#[serde(rename = "$value")]
pitch_or_rest: PitchRest,
pub pitch_or_rest: PitchRest,
#[serde(skip_serializing_if = "Option::is_none")]
duration: Option<String>,
voice: String,
pub duration: Option<String>,
pub voice: String,
#[serde(rename = "type")]
r#type: String,
pub r#type: String,
#[serde(skip_serializing_if = "Option::is_none")]
stem: Option<String>,
pub stem: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
dot: Option<DotElement>,
pub dot: Option<DotElement>,
#[serde(skip_serializing_if = "Option::is_none")]
time_modification: Option<TimeModificationElement>,
staff: String,
pub time_modification: Option<TimeModificationElement>,
pub staff: String,
#[serde(skip_serializing_if = "Option::is_none")]
beam: Option<Vec<BeamElement>>,
pub beam: Option<Vec<BeamElement>>,
#[serde(skip_serializing_if = "Option::is_none")]
notations: Option<NotationsElement>,
pub notations: Option<NotationsElement>,
}

impl NoteElement {
pub fn insert_stop_tuple(&mut self, tuplet_number: String) {
if self.notations.is_some() {
let ne = self.notations.as_mut().unwrap();
ne.notations.push(Notations::Tuplet(TupletElement {
r#type: TupletType::Stop,
number: tuplet_number,
}));
} else {
self.notations = Some(NotationsElement {
notations: vec![Notations::Tuplet(TupletElement {
r#type: TupletType::Stop,
number: tuplet_number,
})],
});
}
}

pub fn clear_time_mods(&mut self) {
self.time_modification = None;
}
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
Expand Down
4 changes: 2 additions & 2 deletions src/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::muxml_types::{Part, PartListElement, ScorePart, Measure};
use crate::error::{Error, Result};

pub struct CompleteParts {
part_list: PartListElement,
part_elements: Vec<Part>,
pub part_list: PartListElement,
pub part_elements: Vec<Part>,
}

impl CompleteParts {
Expand Down

0 comments on commit b0fd664

Please sign in to comment.