pub trait ObjectData:
AsAny
+ Any
+ Send
+ Sync {
// Required methods
fn event(
self: Arc<Self>,
backend: &Backend,
msg: Message<ObjectId, OwnedFd>,
) -> Option<Arc<dyn ObjectData>>;
fn destroyed(&self, object_id: ObjectId);
// Provided methods
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error> { ... }
fn data_as_any(&self) -> &(dyn Any + 'static) { ... }
}Expand description
A trait representing your data associated to an object
You will only be given access to it as a & reference, so you
need to handle interior mutability by yourself.
The methods of this trait will be invoked internally every time a new object is created to initialize its data.
Required Methods§
Provided Methods§
Sourcefn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Helper for forwarding a Debug implementation of your ObjectData type
By default will just print ObjectData { ... }
Sourcefn data_as_any(&self) -> &(dyn Any + 'static)
fn data_as_any(&self) -> &(dyn Any + 'static)
Helper for accessing user data
This function is used to back the Proxy::data() function in wayland_client. By default,
it returns self, but this may be overridden to allow downcasting user data
without needing to have access to the full type.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".