Struct wayland_client::Filter

source ·
pub struct Filter<E> {
    inner: Rc<Inner<E, dyn FnMut(E, &Filter<E>, DispatchData<'_>)>, Global>,
}
Expand description

An event filter

Can be used in wayland-client and wayland-server to aggregate messages from different objects into the same closure.

You need to provide it a closure of type FnMut(E, &Filter<E>), which will be called any time a message is sent to the filter via the send(..) method. Your closure also receives a handle to the filter as argument, so that you can use it from within the callback (to assign new wayland objects to this filter for example).

The Filter can be cloned, and all clones send messages to the same closure. However it is not threadsafe.

Fields§

§inner: Rc<Inner<E, dyn FnMut(E, &Filter<E>, DispatchData<'_>)>, Global>

Implementations§

source§

impl<E> Filter<E>

source

pub fn new<F>(f: F) -> Filter<E>where F: FnMut(E, &Filter<E>, DispatchData<'_>) + 'static,

Create a new filter from given closure

source

pub fn send(&self, evt: E, data: DispatchData<'_>)

Send a message to this filter

Trait Implementations§

source§

impl<E> Clone for Filter<E>

source§

fn clone(&self) -> Filter<E>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<E> Debug for Filter<E>where E: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E> !RefUnwindSafe for Filter<E>

§

impl<E> !Send for Filter<E>

§

impl<E> !Sync for Filter<E>

§

impl<E> Unpin for Filter<E>

§

impl<E> !UnwindSafe for Filter<E>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.