Trait wayland_commons::Implementation
[−]
[src]
pub trait Implementation<Meta, Msg>: Downcast { fn receive(&mut self, msg: Msg, meta: Meta); }
Trait representing implementations for wayland objects
Several wayland objects require you to act when some messages are received. You program this act by providing an object implementing this trait.
The trait requires a single method: self.receive(message, metadata)
.
the message
argument will often be an enum of the possible messages,
and the metadata
argument contains associated information. Typically
an handle to the wayland object that received this message.
The trait is automatically implemented for FnMut(Msg, Meta)
closures.
This is mostly used as a trait object in wayland-client
and wayland-server
,
and thus also provide methods providing Any
-like downcasting functionnality.
See also the downcast_impl
freestanding function.
Required Methods
fn receive(&mut self, msg: Msg, meta: Meta)
Receive a message
Methods
impl<Meta, Msg> Implementation<Meta, Msg> where
Meta: Any + 'static,
Msg: Any + 'static,
Meta: Any + 'static,
Msg: Any + 'static,
pub fn is<__T: Implementation<Meta, Msg>>(&self) -> bool
Returns true if the boxed type is the same as __T
.
pub fn downcast_ref<__T: Implementation<Meta, Msg>>(&self) -> Option<&__T>
Returns a reference to the boxed value if it is of type __T
, or
None
if it isn't.
pub fn downcast_mut<__T: Implementation<Meta, Msg>>(
&mut self
) -> Option<&mut __T>
&mut self
) -> Option<&mut __T>
Returns a mutable reference to the boxed value if it is of type
__T
, or None
if it isn't.
Implementors
impl<Meta, Msg, F> Implementation<Meta, Msg> for F where
F: FnMut(Msg, Meta) + 'static,