Skip to content

Commit

Permalink
Add no_std parsing instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgecrw committed Nov 4, 2024
1 parent ff68b7a commit bc6ea0d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ be robust and reliable, handling a wide variety of MusicXML files and formats wi
- Supports both "partwise" and "timewise" data representations
- Allows for transparent conversion between the partwise and timewise representations
- Is provided as a Rust-format library so that it can be link-time optimized with your own code
- Is `no_std` compatible with default features turned off

## Getting Started

To use this library in your Rust project, simply add the following line to your `Cargo.toml` file:

```toml
[dependencies]
musicxml = "1.0"
musicxml = "1.1"
```

You can then parse any regular MusicXML file or compressed MXL file into a structured data format using:
Expand All @@ -49,6 +50,9 @@ match read_score_timewise("path/to/file.musicxml") {
}
```

If you are using this library in a `no_std` environment, you can parse MusicXML data directly by instead
calling the `read_score_data_partwise()` and `read_score_data_timewise()` functions.

Please refer to the [library documentation](https://docs.rs/musicxml/latest/) for full usage instructions.
You may also want to consult the official [MusicXML Standard](https://www.w3.org/2021/06/musicxml40/) for additional
details.
Expand All @@ -60,6 +64,8 @@ This library is licensed under the [MIT license](http://opensource.org/licenses/

## TODO

- [ ] Add documentation about "std" feature, including parsing to/from a data buffer instead of a file
- [ ] Remove dependency on regex
- [ ] Create WASM build

- Finish ZIP writing
- Test all new stuff
10 changes: 9 additions & 1 deletion musicxml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
//!
//! Note that this library is able to read both `.musicxml` files and compressed `.mxl` files. The file type being read is
//! determined internally, and decoding will be handled automatically when calling either of the above functions.
//!
//! If you are using this library in a `no_std` environment, you can parse MusicXML data directly by calling the
//! [read_score_data_partwise] and [read_score_data_timewise] functions. These functions take a `Vec<u8>` containing
//! raw MusicXML data and return a [ScorePartwise] or [ScoreTimewise] object, respectively.
//!
//! # Writing MusicXML Files
//!
Expand All @@ -93,7 +97,8 @@
//! }
//! ```
//!
//! Alternately, to write a [ScoreTimewise] object to a compressed MusicXML file using a partwise representation, you can do the following:
//! Alternately, to write a [ScoreTimewise] object to a compressed MusicXML file using a partwise representation,
//! you can do the following:
//!
//! ```ignore
//! use musicxml::write_timewise_score;
Expand All @@ -104,6 +109,9 @@
//! Err(e) => println!("Error writing compressed MusicXML file: {}", e),
//! }
//! ```
//!
//! As with reading data, if you are using this library in a `no_std` environment, you can write MusicXML data
//! directly to a data buffer by calling the [write_partwise_score_data] and [write_timewise_score_data] functions.
#[macro_use]
extern crate alloc;
Expand Down

0 comments on commit bc6ea0d

Please sign in to comment.