midir/
lib.rs

1#![warn(future_incompatible)]
2#![warn(rust_2018_idioms)]
3#![warn(rust_2021_compatibility)]
4
5#[cfg(feature = "jack")]
6#[macro_use]
7extern crate bitflags;
8
9#[repr(u8)]
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11/// An enum that is used to specify what kind of MIDI messages should
12/// be ignored when receiving messages.
13pub enum Ignore {
14    None = 0x00,
15    Sysex = 0x01,
16    Time = 0x02,
17    SysexAndTime = 0x03,
18    ActiveSense = 0x04,
19    SysexAndActiveSense = 0x05,
20    TimeAndActiveSense = 0x06,
21    All = 0x07,
22}
23
24impl std::ops::BitOr for Ignore {
25    type Output = Ignore;
26    #[inline(always)]
27    fn bitor(self, rhs: Self) -> Self::Output {
28        // this is safe because all combinations also exist as variants
29        unsafe { std::mem::transmute(self as u8 | rhs as u8) }
30    }
31}
32
33impl Ignore {
34    #[inline(always)]
35    pub fn contains(self, other: Ignore) -> bool {
36        self as u8 & other as u8 != 0
37    }
38}
39
40/// A MIDI structure used internally by some backends to store incoming
41/// messages. Each message represents one and only one MIDI message.
42/// The timestamp is represented as the elapsed microseconds since
43/// a point in time that is arbitrary, but does not change for the
44/// lifetime of a given MidiInputConnection.
45#[derive(Debug, Clone)]
46struct MidiMessage {
47    bytes: Vec<u8>,
48    timestamp: u64,
49}
50
51impl MidiMessage {
52    fn new() -> MidiMessage {
53        MidiMessage {
54            bytes: vec![],
55            timestamp: 0,
56        }
57    }
58}
59
60pub mod os; // include platform-specific behaviour
61
62mod errors;
63pub use errors::*;
64
65mod common;
66pub use common::*;
67
68mod backend;