Skip to content

Commit 76f784a

Browse files
author
Ben Leadbetter
committed
Merge branch 'release/0.2.4'
2 parents a7c6669 + 6abb4f1 commit 76f784a

File tree

15 files changed

+318
-38
lines changed

15 files changed

+318
-38
lines changed

.github/workflows/rust.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ "main", "develop" ]
6+
pull_request:
7+
branches: [ "main", "develop" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Build
23+
run: cargo build --verbose --all-features
24+
- name: Run tests
25+
run: cargo test --verbose --all-features

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 0.2.4
2+
ci: add standard cargo github actions
3+
docs: fix various typos
4+
docs: online docs generated with all features enabled
5+
fix: sysex7 / sysex8 payload iterator integration with jr headers
6+
fix: sysex7 / sysex8 payload iterator panics when empty
7+
test: add fuzzing target for sysex7 and sysex8 roundtrip
8+
19
# 0.2.3
210
fix: handling messages example code
311
fix: default features include cv2 not cv1

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "midi2"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
description = "Ergonomic, versatile, strong types wrapping MIDI 2.0 message data."
55
edition = "2021"
66
readme = "README.md"
@@ -13,6 +13,7 @@ repository = "https://github.com/BenLeadbetter/midi2.git"
1313
[workspace]
1414
members = [
1515
"midi2_proc",
16+
"fuzz",
1617
]
1718

1819
[lib]
@@ -33,8 +34,11 @@ ump-stream = []
3334

3435
[dependencies]
3536
derive_more = { version = "0.99.17", features = ["from"], default-features = false }
36-
midi2_proc = { version = "0.2.3", path = "midi2_proc" }
37+
midi2_proc = { version = "0.2.4", path = "midi2_proc" }
3738
ux = "0.1.6"
3839

3940
[dev-dependencies]
4041
pretty_assertions = "1.4.0"
42+
43+
[package.metadata.docs.rs]
44+
all-features = true

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ You'll want to setup midi2 without default features to compile
176176
without the `std` feature.
177177

178178
```toml
179-
// Cargo.toml
180-
midi2 = { version = "0.2.3", default-features = false, features = [<required-message-types>], }
179+
midi2 = { version = "0.2.4", default-features = false, features = ["channel-voice2", "sysex7"], }
181180
```
182181

183182
### Generic Representation
@@ -254,7 +253,7 @@ owned.set_jitter_reduction(Some(JitterReduction::Timestamp(0x1234)));
254253
assert_eq!(owned.data(), &[0x0020_1234, 0x1AF3_4F00])
255254
```
256255

257-
## Supports For Classical MIDI Byte Stream Messages
256+
## Support For Classical MIDI Byte Stream Messages
258257

259258
Messages which can be represented in classical midi byte stream format are also supported.
260259
To do this simply use a backing buffer over `u8` instead of `u32`! ✨🎩

fuzz/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target
2+
corpus
3+
artifacts
4+
coverage

fuzz/Cargo.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[package]
2+
name = "midi2-fuzz"
3+
version = "0.0.0"
4+
publish = false
5+
edition = "2021"
6+
7+
[package.metadata]
8+
cargo-fuzz = true
9+
10+
[dependencies]
11+
libfuzzer-sys = "0.4"
12+
13+
[dependencies.midi2]
14+
path = ".."
15+
default-features = false
16+
features = [
17+
"std",
18+
"sysex8",
19+
"sysex7",
20+
]
21+
22+
[[bin]]
23+
name = "sysex8_payload_roundtrip"
24+
path = "./fuzz_targets/sysex8_payload_roundtrip.rs"
25+
test = false
26+
doc = false
27+
bench = false
28+
29+
[[bin]]
30+
name = "sysex7_payload_roundtrip"
31+
path = "./fuzz_targets/sysex7_payload_roundtrip.rs"
32+
test = false
33+
doc = false
34+
bench = false
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![no_main]
2+
3+
use libfuzzer_sys::fuzz_target;
4+
use midi2::{prelude::*, sysex7::*};
5+
6+
fuzz_target!(|data: &[u8]| {
7+
let to_u7 = |b: u8| u7::new(b & 0x7F);
8+
let mut message = Sysex7::<Vec<u32>>::new();
9+
message.set_payload(data.iter().cloned().map(to_u7));
10+
11+
// payload is unchanged
12+
let payload = message.payload().collect::<Vec<u7>>();
13+
assert_eq!(
14+
payload,
15+
data.iter().cloned().map(to_u7).collect::<Vec<u7>>()
16+
);
17+
18+
// message is in a valid state
19+
let mut buffer = Vec::new();
20+
buffer.extend_from_slice(message.data());
21+
let _ = Sysex7::try_from(&buffer[..]).expect("Valid data");
22+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![no_main]
2+
3+
use libfuzzer_sys::fuzz_target;
4+
use midi2::{prelude::*, sysex8::*};
5+
6+
fuzz_target!(|data: &[u8]| {
7+
let mut message = Sysex8::<Vec<u32>>::new();
8+
message.set_payload(data.iter().cloned());
9+
10+
// payload is unchanged
11+
let payload = message.payload().collect::<Vec<u8>>();
12+
assert_eq!(payload, data.iter().cloned().collect::<Vec<u8>>());
13+
14+
// message is in a valid state
15+
let mut buffer = Vec::new();
16+
buffer.extend_from_slice(message.data());
17+
let _ = Sysex8::try_from(&buffer[..]).expect("Valid data");
18+
});

midi2_proc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "midi2_proc"
33
description = "Internal procedural macro crate. Only intended for use with midi2"
4-
version = "0.2.3"
4+
version = "0.2.4"
55
edition = "2021"
66
readme = "README.md"
77
license = "MIT OR Apache-2.0"

src/buffer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Generic backing buffers for messages wrapper types.
2-
//!
2+
//!
33
//! All messages in midi2 are backed by a generic buffer type.
44
//!
55
//! A buffer can be any data type which returns a slice of `u32` or `u8`.
@@ -10,8 +10,8 @@
1010
//! * `[U; SIZE] where U: Unit`
1111
//! * `Vec<U> where U: Unit` (with the `std` feature enabled)
1212
//!
13-
//! The api of the message wrapper changes depending on the traits of the
14-
//! backing buffer.
13+
//! The api of the message wrapper changes depending on the traits of the
14+
//! backing buffer.
1515
//!
1616
//! For example `&[U]` implements [Buffer]
1717
//! but doesn't implement [BufferMut] so messages
@@ -29,7 +29,7 @@
2929
//! assert_eq!(message.note(), u7::default());
3030
//!
3131
//! // error[E0277]: the trait bound `&[u32]: BufferMut` is not satisfied
32-
//! message.set_note(u7::new(0x60));
32+
//! message.set_note(u7::new(0x60));
3333
//! ```
3434
//!
3535
//! `[U: SIZE]` buffers implement [BufferMut], but only
@@ -44,7 +44,7 @@
4444
//! assert_eq!(message.try_set_payload(0..20), Ok(()));
4545
//! ```
4646
//! `Vec<U>` implements [BufferMut] and [BufferResize].
47-
//! Messages backed with with such buffers have the most powerfull api.
47+
//! Messages backed with with such buffers have the most powerful api.
4848
//!
4949
//! ```rust
5050
//! use midi2::prelude::*;
@@ -59,7 +59,7 @@
5959
//! possible to create a custom backing buffer.
6060
//!
6161
//! One potential fancy use case might be to create a non-allocating
62-
//! resizable buffer which uses an area allocator.
62+
//! resizable buffer which uses an arena allocator.
6363
6464
use crate::error::BufferOverflow;
6565

0 commit comments

Comments
 (0)