Debian Codegraph @

third_party/rust/coremidi/src/endpoints/mod.rs

raw
1 pub mod destinations;
2 pub mod sources;
3
4 use std::ops::Deref;
5
6 use core_foundation_sys::base::OSStatus;
7 use coremidi_sys::MIDIFlushOutput;
8
9 use crate::object::Object;
10
11 /// A MIDI source or source, owned by an entity.
12 /// See [MIDIEndpointRef](https://developer.apple.com/reference/coremidi/midiendpointref).
13 ///
14 /// You don't need to create an endpoint directly, instead you can create system sources and sources or virtual ones from a client.
15 ///
16 #[derive(Debug)]
17 pub struct Endpoint {
18 pub(crate) object: Object,
19 }
20
21 impl Endpoint {
22 /// Unschedules previously-sent packets.
23 /// See [MIDIFlushOutput](https://developer.apple.com/reference/coremidi/1495312-midiflushoutput).
24 ///
25 pub fn flush(&self) -> Result<(), OSStatus> {
26 let status = unsafe { MIDIFlushOutput(self.object.0) };
27 if status == 0 {
28 Ok(())
29 } else {
30 Err(status)
31 }
32 }
33 }
34
35 impl AsRef<Object> for Endpoint {
36 fn as_ref(&self) -> &Object {
37 &self.object
38 }
39 }
40
41 impl Deref for Endpoint {
42 type Target = Object;
43
44 fn deref(&self) -> &Object {
45 &self.object
46 }
47 }