diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 7c0e020..23462e1 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -85,28 +85,32 @@ macro_rules! impl_platform_host { )* } - enum DeviceInner { + /// Contains a platform specific `Device` implementation. + pub enum DeviceInner { $( $(#[cfg($feat)])? $HostVariant(crate::host::$host_mod::Device), )* } - enum DevicesInner { + /// Contains a platform specific `Devices` implementation. + pub enum DevicesInner { $( $(#[cfg($feat)])? $HostVariant(crate::host::$host_mod::Devices), )* } - enum HostInner { + /// Contains a platform specific `Host` implementation. + pub enum HostInner { $( $(#[cfg($feat)])? $HostVariant(crate::host::$host_mod::Host), )* } - enum StreamInner { + /// Contains a platform specific `Stream` implementation. + pub enum StreamInner { $( $(#[cfg($feat)])? $HostVariant(crate::host::$host_mod::Stream), @@ -138,6 +142,44 @@ macro_rules! impl_platform_host { } } + impl Devices { + /// Returns a reference to the underlying platform specific implementation of this + /// `Devices`. + pub fn as_inner(&self) -> &DevicesInner { + &self.0 + } + + /// Returns a mutable reference to the underlying platform specific implementation of + /// this `Devices`. + pub fn as_inner_mut(&mut self) -> &mut DevicesInner { + &mut self.0 + } + + /// Returns the underlying platform specific implementation of this `Devices`. + pub fn into_inner(self) -> DevicesInner { + self.0 + } + } + + impl Device { + /// Returns a reference to the underlying platform specific implementation of this + /// `Device`. + pub fn as_inner(&self) -> &DeviceInner { + &self.0 + } + + /// Returns a mutable reference to the underlying platform specific implementation of + /// this `Device`. + pub fn as_inner_mut(&mut self) -> &mut DeviceInner { + &mut self.0 + } + + /// Returns the underlying platform specific implementation of this `Device`. + pub fn into_inner(self) -> DeviceInner { + self.0 + } + } + impl Host { /// The unique identifier associated with this host. pub fn id(&self) -> HostId { @@ -148,6 +190,42 @@ macro_rules! impl_platform_host { )* } } + + /// Returns a reference to the underlying platform specific implementation of this + /// `Host`. + pub fn as_inner(&self) -> &HostInner { + &self.0 + } + + /// Returns a mutable reference to the underlying platform specific implementation of + /// this `Host`. + pub fn as_inner_mut(&mut self) -> &mut HostInner { + &mut self.0 + } + + /// Returns the underlying platform specific implementation of this `Host`. + pub fn into_inner(self) -> HostInner { + self.0 + } + } + + impl Stream { + /// Returns a reference to the underlying platform specific implementation of this + /// `Stream`. + pub fn as_inner(&self) -> &StreamInner { + &self.0 + } + + /// Returns a mutable reference to the underlying platform specific implementation of + /// this `Stream`. + pub fn as_inner_mut(&mut self) -> &mut StreamInner { + &mut self.0 + } + + /// Returns the underlying platform specific implementation of this `Stream`. + pub fn into_inner(self) -> StreamInner { + self.0 + } } impl Iterator for Devices {