Skip to content

Commit

Permalink
Removed From<CodeIndexNumber> for U4 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcebox committed Dec 21, 2024
1 parent abf5166 commit d7a7b99
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ This release focuses on:
- `UsbMidiEventPacket::from_midi` function, use `Message::into_packet` instead.
- `CodeIndexNumber::find_from_message` function, use `Message::code_index_number` instead.
- `From<CableNumber> for U4` implementation.
- `From<CodeIndexNumber> for U4` implementation.

## [0.3.0] - 2024-05-27

Expand Down
3 changes: 1 addition & 2 deletions src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub mod control_function;
pub mod notes;
pub mod raw;

use crate::data::u4::U4;
use crate::data::u7::U7;
use crate::data::FromClamped;
use crate::message::channel::Channel;
Expand Down Expand Up @@ -149,7 +148,7 @@ impl TryFrom<&UsbMidiEventPacket> for Message {
impl Message {
/// Create a packet from the message.
pub fn into_packet(self, cable: CableNumber) -> UsbMidiEventPacket {
let cin = u8::from(U4::from(self.code_index_number()));
let cin = self.code_index_number() as u8;

let mut raw = [0; 4];
raw[0] = (cable as u8) << 4 | cin;
Expand Down
7 changes: 0 additions & 7 deletions src/packet/code_index_number.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Enum representing the code index number of a packet.
use crate::data::u4::U4;
use crate::packet::MidiPacketParsingError;

/// The Code Index Number(CIN) indicates the classification
Expand Down Expand Up @@ -85,12 +84,6 @@ impl TryFrom<u8> for CodeIndexNumber {
}
}

impl From<CodeIndexNumber> for U4 {
fn from(value: CodeIndexNumber) -> U4 {
U4::from_overflowing_u8(value as u8)
}
}

impl CodeIndexNumber {
/// Creates a new number from a MIDI event payload.
pub fn try_from_payload(payload: &[u8]) -> Result<Self, MidiPacketParsingError> {
Expand Down

0 comments on commit d7a7b99

Please sign in to comment.