Debian Codegraph @

third_party/rust/midir/src/lib.rs

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