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§

source

fn listeners( &self ) -> &Listeners<Pin<Box<<<Self as Wrapper>::RawWrapperType as AddListener<'a>>::Events>>>

Listeners storege

Provided Methods§

source

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.

source

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.

source

fn contains_listener(&self, id: ListenerId) -> bool

Whether the storage contains listener with the given id.

Implementors§

source§

impl<'a> OwnListeners<'a> for Client<'a>

source§

impl<'a> OwnListeners<'a> for Device<'a>

source§

impl<'a> OwnListeners<'a> for Factory<'a>

source§

impl<'a> OwnListeners<'a> for Link<'a>

source§

impl<'a> OwnListeners<'a> for Node<'a>

source§

impl<'a> OwnListeners<'a> for Port<'a>

source§

impl<'a> OwnListeners<'a> for Registry<'a>

source§

impl<'a> OwnListeners<'a> for Stream<'a>

source§

impl<'a, T: 'a> OwnListeners<'a> for Filter<'a, T>