Expose underlying platform specific implemenations (#660)
* expose underlying platform specific implemenations * add doc to Inner enums * fix: return `&mut` from `as_inner_mut`
This commit is contained in:
parent
a420316e30
commit
8d164ed585
1 changed files with 82 additions and 4 deletions
|
|
@ -85,28 +85,32 @@ macro_rules! impl_platform_host {
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DeviceInner {
|
/// Contains a platform specific `Device` implementation.
|
||||||
|
pub enum DeviceInner {
|
||||||
$(
|
$(
|
||||||
$(#[cfg($feat)])?
|
$(#[cfg($feat)])?
|
||||||
$HostVariant(crate::host::$host_mod::Device),
|
$HostVariant(crate::host::$host_mod::Device),
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DevicesInner {
|
/// Contains a platform specific `Devices` implementation.
|
||||||
|
pub enum DevicesInner {
|
||||||
$(
|
$(
|
||||||
$(#[cfg($feat)])?
|
$(#[cfg($feat)])?
|
||||||
$HostVariant(crate::host::$host_mod::Devices),
|
$HostVariant(crate::host::$host_mod::Devices),
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
enum HostInner {
|
/// Contains a platform specific `Host` implementation.
|
||||||
|
pub enum HostInner {
|
||||||
$(
|
$(
|
||||||
$(#[cfg($feat)])?
|
$(#[cfg($feat)])?
|
||||||
$HostVariant(crate::host::$host_mod::Host),
|
$HostVariant(crate::host::$host_mod::Host),
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
enum StreamInner {
|
/// Contains a platform specific `Stream` implementation.
|
||||||
|
pub enum StreamInner {
|
||||||
$(
|
$(
|
||||||
$(#[cfg($feat)])?
|
$(#[cfg($feat)])?
|
||||||
$HostVariant(crate::host::$host_mod::Stream),
|
$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 {
|
impl Host {
|
||||||
/// The unique identifier associated with this host.
|
/// The unique identifier associated with this host.
|
||||||
pub fn id(&self) -> HostId {
|
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 {
|
impl Iterator for Devices {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue