Debian Codegraph @

third_party/rust/midir/src/os/unix.rs

raw
1 use ::ConnectError;
2 use ::{MidiInputConnection, MidiOutputConnection};
3
4 // TODO: maybe move to module `virtual` instead of `os::unix`?
5
6 /// Trait that is implemented by `MidiInput` on platforms that
7 /// support virtual ports (currently every platform but Windows).
8 pub trait VirtualInput<T: Send> where Self: Sized {
9 /// Creates a virtual input port. Once it has been created,
10 /// other applications can connect to this port and send MIDI
11 /// messages which will be received by this port.
12 fn create_virtual<F>(
13 self, port_name: &str, callback: F, data: T
14 ) -> Result<MidiInputConnection<T>, ConnectError<Self>>
15 where F: FnMut(u64, &[u8], &mut T) + Send + 'static;
16 }
17
18 /// Trait that is implemented by `MidiOutput` on platforms that
19 /// support virtual ports (currently every platform but Windows).
20 pub trait VirtualOutput where Self: Sized {
21 /// Creates a virtual output port. Once it has been created,
22 /// other applications can connect to this port and will
23 /// receive MIDI messages that are sent to this port.
24 fn create_virtual(
25 self, port_name: &str
26 ) -> Result<MidiOutputConnection, ConnectError<Self>>;
27 }