Trait wayland_client::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> + 'static where
Meta: Any + 'static,
Msg: Any + 'static,
impl<Meta, Msg> Implementation<Meta, Msg> + 'static where
Meta: Any + 'static,
Msg: Any + 'static,
pub fn is<__T>(&self) -> bool where
__T: Implementation<Meta, Msg>,
pub fn is<__T>(&self) -> bool where
__T: Implementation<Meta, Msg>,
Returns true if the trait object wraps an object of type __T
.
pub fn downcast<__T>(
self: Box<Implementation<Meta, Msg> + 'static>
) -> Result<Box<__T>, Box<Implementation<Meta, Msg> + 'static>> where
__T: Implementation<Meta, Msg>,
pub fn downcast<__T>(
self: Box<Implementation<Meta, Msg> + 'static>
) -> Result<Box<__T>, Box<Implementation<Meta, Msg> + 'static>> where
__T: Implementation<Meta, Msg>,
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>(&self) -> Option<&__T> where
__T: Implementation<Meta, Msg>,
pub fn downcast_ref<__T>(&self) -> Option<&__T> where
__T: Implementation<Meta, Msg>,
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>(&mut self) -> Option<&mut __T> where
__T: Implementation<Meta, Msg>,
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T> where
__T: Implementation<Meta, Msg>,
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,