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 become wl_buffer::v1::Request.
  • interface - The interface name. By default, this attribute finds the parent of the RequestDispatch trait, i.e. wl_buffer::v1::RequestDispatch will become wl_buffer::v1; then attach ::NAME to it as the interface.
  • on_disconnect - The function to call when the client disconnects. Used for the Object::on_disconnect impl.
  • crate - The path to the runa_core crate. “runa_core” by default.
  • state - The type of the singleton state associated with the object. See MonoObject::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 for MonoObject.
  • state_init - An expression to create the initial value of the state. This expression must be evaluate-able in const context. By default, if state is not set, this will be (); otherwise this will be Default::default, which must be defined as an associated constant. Note you don’t need to wrap this in Some.