AudioSetup now stores children as OnOff instead of Device as that is all that is required

This commit is contained in:
2023-01-07 05:00:59 +01:00
parent 8bc203cb2d
commit a638de42c1
3 changed files with 37 additions and 32 deletions

View File

@@ -5,11 +5,15 @@ macro_rules! impl_cast {
($base:ident, $trait:ident) => {
$crate::paste::paste! {
pub trait [< As $trait>] {
fn consume(self: Box<Self>) -> Option<Box<dyn $trait + Sync + Send>>;
fn cast(&self) -> Option<&dyn $trait>;
fn cast_mut(&mut self) -> Option<&mut dyn $trait>;
}
impl<T: $base> [< As $trait>] for T {
default fn consume(self: Box<Self>) -> Option<Box<dyn $trait + Sync + Send>> {
None
}
default fn cast(&self) -> Option<&dyn $trait> {
None
}
@@ -18,7 +22,10 @@ macro_rules! impl_cast {
}
}
impl<T: $base + $trait> [< As $trait>] for T {
impl<T: $base + $trait + Sync + Send + 'static> [< As $trait>] for T {
fn consume(self: Box<Self>) -> Option<Box<dyn $trait + Sync + Send>> {
Some(self)
}
fn cast(&self) -> Option<&dyn $trait> {
Some(self)
}