use std::rc::Rc;
use maudio_sys::ffi as sys;
use crate::AsRawRef;
#[repr(transparent)]
#[derive(Clone)]
pub struct DeviceId {
inner: Rc<DeviceIdInner>,
}
struct DeviceIdInner {
inner: sys::ma_device_id,
}
impl AsRawRef for DeviceId {
type Raw = sys::ma_device_id;
fn as_raw(&self) -> &Self::Raw {
&self.inner.inner
}
}
impl DeviceId {
pub(crate) fn new(id: sys::ma_device_id) -> Self {
Self {
inner: Rc::new(DeviceIdInner { inner: id }),
}
}
}
impl PartialEq for DeviceId {
fn eq(&self, other: &Self) -> bool {
unsafe { sys::ma_device_id_equal(self.as_raw_ptr(), other.as_raw_ptr()) != 0 }
}
}
impl Eq for DeviceId {}