Trait pipewire_wrapper::listeners::OwnListeners
source · pub trait OwnListeners<'a>where
Self: Wrapper,
<Self as Wrapper>::RawWrapperType: AddListener<'a>,{
// Required method
fn listeners(
&self
) -> &Listeners<Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>>;
// Provided methods
fn add_listener(
&self,
events: Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>
) -> ListenerId { ... }
fn remove_listener(
&'a mut self,
id: ListenerId
) -> Option<Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>> { ... }
fn contains_listener(&self, id: ListenerId) -> bool { ... }
}
Expand description
Wrapper that can register and store events listeners.
Example
ⓘ
use pipewire_wrapper::core_api::device::DeviceRef;
use pipewire_wrapper::core_api::registry::events::RegistryEventsBuilder;
use crate::pipewire_wrapper::core_api::proxy::Proxied;
let listener = RegistryEventsBuilder::default()
.global(Box::new(
move |id, _permissions, type_info, _version, _props| {
if type_info == DeviceRef::type_info() {
device_added_queue.lock().unwrap().push(id);
main_loop.signal_event(&device_added_event).unwrap();
}
},
))
.build();
registry.add_listener(listener)
Required Methods§
sourcefn listeners(
&self
) -> &Listeners<Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>>
fn listeners( &self ) -> &Listeners<Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>>
Listeners storege
Provided Methods§
sourcefn add_listener(
&self,
events: Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>
) -> ListenerId
fn add_listener( &self, events: Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>> ) -> ListenerId
Register new listener and add it to storage.
Arguments
events
- new events listener
Returns ListenerId that can be used to remove listener from storage.
sourcefn remove_listener(
&'a mut self,
id: ListenerId
) -> Option<Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>>
fn remove_listener( &'a mut self, id: ListenerId ) -> Option<Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>>
Remove listener with the given ListenerId from storage.
Notes
The listener will be unsubscribed after drop.
sourcefn contains_listener(&self, id: ListenerId) -> bool
fn contains_listener(&self, id: ListenerId) -> bool
Whether the storage contains listener with the given id.