Attribute Macro runa_core::objects::wayland_object
#[wayland_object]
Expand description
Generate Object
impls for types that implement RequestDispatch
for a
certain interface. Should be attached to RequestDispatch
impls.
It deserialize a message from a deserializer, and calls appropriate function
in the RequestDispatch
based on the message content. Your impl of
RequestDispatch
should contains an error type that can be converted from
deserailization error.
Arguments
message
- The message type. By default, this attribute try to cut the “Dispatch” suffix from the trait name. i.e.wl_buffer::v1::RequestDispatch
will becomewl_buffer::v1::Request
.interface
- The interface name. By default, this attribute finds the parent of theRequestDispatch
trait, i.e.wl_buffer::v1::RequestDispatch
will becomewl_buffer::v1
; then attach::NAME
to it as the interface.on_disconnect
- The function to call when the client disconnects. Used for theObject::on_disconnect
impl.crate
- The path to theruna_core
crate. “runa_core” by default.state
- The type of the singleton state associated with the object. SeeMonoObject::SingletonState
for more information. If not set, this will be a unit type (e.g.()
). An optional where clause can be added, which will be attached to the impl forMonoObject
.state_init
- An expression to create the initial value of the state. This expression must be evaluate-able in const context. By default, ifstate
is not set, this will be()
; otherwise this will beDefault::default
, which must be defined as an associated constant. Note you don’t need to wrap this inSome
.