Skip to main content

ObjectData

Trait ObjectData 

Source
pub trait ObjectData<D>:
    Any
    + Send
    + Sync {
    // Required methods
    fn request(
        self: Arc<Self>,
        handle: &Handle,
        data: &mut D,
        client_id: ClientId,
        msg: Message<ObjectId, OwnedFd>,
    ) -> Option<Arc<dyn ObjectData<D>>>;
    fn destroyed(
        self: Arc<Self>,
        handle: &Handle,
        data: &mut D,
        client_id: ClientId,
        object_id: ObjectId,
    );

    // Provided method
    fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error> { ... }
}
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§

Source

fn request( self: Arc<Self>, handle: &Handle, data: &mut D, client_id: ClientId, msg: Message<ObjectId, OwnedFd>, ) -> Option<Arc<dyn ObjectData<D>>>

Dispatch a request for the associated object

If the request has a NewId argument, the callback must return the object data for the newly created object

Source

fn destroyed( self: Arc<Self>, handle: &Handle, data: &mut D, client_id: ClientId, object_id: ObjectId, )

Notification that the object has been destroyed and is no longer active

Provided Methods§

Source

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Helper for forwarding a Debug implementation of your ObjectData type

By default will just print ObjectData { ... }

Trait Implementations§

Source§

impl<D> Debug for dyn ObjectData<D>
where D: 'static,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Implementors§

Source§

impl<I: Resource + 'static, D: 'static, U: Dispatch<I, D> + Send + Sync + 'static> ObjectData<D> for ResourceData<I, U>