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§
Sourcefn request(
self: Arc<Self>,
handle: &Handle,
data: &mut D,
client_id: ClientId,
msg: Message<ObjectId, OwnedFd>,
) -> Option<Arc<dyn ObjectData<D>>>
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