Trait wayland_commons::Implementation [−][src]
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,
impl<Meta, Msg> Implementation<Meta, Msg> where
Meta: Any + 'static,
Msg: Any + 'static, pub fn is<__T: Implementation<Meta, Msg>>(&self) -> bool
pub fn is<__T: Implementation<Meta, Msg>>(&self) -> boolReturns true if the trait object wraps an object of type __T.
pub fn downcast<__T: Implementation<Meta, Msg>>(
self: Box<Self>
) -> Result<Box<__T>, Box<Self>>
pub fn downcast<__T: Implementation<Meta, Msg>>(
self: Box<Self>
) -> Result<Box<__T>, Box<Self>>Returns a boxed object from a boxed trait object if the underlying object is of type
__T. Returns the original boxed trait if it isn't.
pub fn downcast_ref<__T: Implementation<Meta, Msg>>(&self) -> Option<&__T>
pub fn downcast_ref<__T: Implementation<Meta, Msg>>(&self) -> Option<&__T>Returns a reference to the object within the trait object 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>
pub fn downcast_mut<__T: Implementation<Meta, Msg>>(
&mut self
) -> Option<&mut __T>Returns a mutable reference to the object within the trait object 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,