1
0
Fork 0
forked from wry/wry

wire: generate trait for request handling

This commit is contained in:
Julian Orth 2024-04-08 17:37:35 +02:00
parent e3a1a0b30f
commit acb391335b
102 changed files with 1632 additions and 2086 deletions

View file

@ -8,7 +8,6 @@ use {
},
leaks::Tracker,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{zwp_primary_selection_device_manager_v1::*, ZwpPrimarySelectionDeviceManagerV1Id},
},
std::rc::Rc,
@ -49,23 +48,21 @@ impl ZwpPrimarySelectionDeviceManagerV1Global {
}
}
impl ZwpPrimarySelectionDeviceManagerV1 {
fn create_source(
&self,
parser: MsgParser<'_, '_>,
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
let req: CreateSource = self.client.parse(self, parser)?;
let res = Rc::new(ZwpPrimarySelectionSourceV1::new(req.id, &self.client));
impl ZwpPrimarySelectionDeviceManagerV1RequestHandler for ZwpPrimarySelectionDeviceManagerV1 {
type Error = ZwpPrimarySelectionDeviceManagerV1Error;
fn create_source(&self, req: CreateSource, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let res = Rc::new(ZwpPrimarySelectionSourceV1::new(
req.id,
&self.client,
self.version,
));
track!(self.client, res);
self.client.add_client_obj(&res)?;
Ok(())
}
fn get_data_device(
self: &Rc<Self>,
parser: MsgParser<'_, '_>,
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
let req: GetDevice = self.client.parse(&**self, parser)?;
fn get_device(&self, req: GetDevice, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let seat = self.client.lookup(req.seat)?;
let dev = Rc::new(ZwpPrimarySelectionDeviceV1::new(
req.id,
@ -79,11 +76,7 @@ impl ZwpPrimarySelectionDeviceManagerV1 {
Ok(())
}
fn destroy(
&self,
parser: MsgParser<'_, '_>,
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
let _req: Destroy = self.client.parse(self, parser)?;
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.client.remove_obj(self)?;
Ok(())
}
@ -109,10 +102,7 @@ simple_add_global!(ZwpPrimarySelectionDeviceManagerV1Global);
object_base! {
self = ZwpPrimarySelectionDeviceManagerV1;
CREATE_SOURCE => create_source,
GET_DEVICE => get_data_device,
DESTROY => destroy,
version = self.version;
}
impl Object for ZwpPrimarySelectionDeviceManagerV1 {}
@ -121,10 +111,7 @@ simple_add_obj!(ZwpPrimarySelectionDeviceManagerV1);
#[derive(Debug, Error)]
pub enum ZwpPrimarySelectionDeviceManagerV1Error {
#[error("Parsing failed")]
MsgParserError(#[source] Box<MsgParserError>),
#[error(transparent)]
ClientError(Box<ClientError>),
}
efrom!(ZwpPrimarySelectionDeviceManagerV1Error, ClientError);
efrom!(ZwpPrimarySelectionDeviceManagerV1Error, MsgParserError);