use core_foundation_sys::base::OSStatus;
use std::ops::Deref;
use coremidi_sys::{MIDIEndpointRef, MIDIFlushOutput};
use crate::object::Object;
use crate::unit_result_from_status;
#[derive(Debug, Hash, Eq, PartialEq)]
pub struct Endpoint {
pub(crate) object: Object,
}
impl Endpoint {
pub(crate) fn new(endpoint_ref: MIDIEndpointRef) -> Self {
Self {
object: Object(endpoint_ref),
}
}
pub fn flush(&self) -> Result<(), OSStatus> {
let status = unsafe { MIDIFlushOutput(self.object.0) };
unit_result_from_status(status)
}
}
impl AsRef<Object> for Endpoint {
fn as_ref(&self) -> &Object {
&self.object
}
}
impl Deref for Endpoint {
type Target = Object;
fn deref(&self) -> &Object {
&self.object
}
}