use { crate::{ client::{Client, ClientError}, globals::{Global, GlobalName}, leaks::Tracker, object::{Object, Version}, wire::{WlFixesId, wl_fixes::*}, }, std::rc::Rc, thiserror::Error, }; pub struct WlFixesGlobal { pub name: GlobalName, } impl WlFixesGlobal { pub fn new(name: GlobalName) -> Self { Self { name } } fn bind_( self: Rc, id: WlFixesId, client: &Rc, version: Version, ) -> Result<(), WlFixesError> { let mgr = Rc::new(WlFixes { id, client: client.clone(), tracker: Default::default(), version, }); track!(client, mgr); client.add_client_obj(&mgr)?; Ok(()) } } global_base!(WlFixesGlobal, WlFixes, WlFixesError); simple_add_global!(WlFixesGlobal); impl Global for WlFixesGlobal { fn version(&self) -> u32 { 1 } } pub struct WlFixes { pub id: WlFixesId, pub client: Rc, pub tracker: Tracker, pub version: Version, } impl WlFixesRequestHandler for WlFixes { type Error = WlFixesError; fn destroy(&self, _req: Destroy, _slf: &Rc) -> Result<(), Self::Error> { self.client.remove_obj(self)?; Ok(()) } fn destroy_registry(&self, req: DestroyRegistry, _slf: &Rc) -> Result<(), Self::Error> { let registry = self.client.lookup(req.registry)?; self.client.remove_obj(&*registry)?; Ok(()) } } object_base! { self = WlFixes; version = self.version; } impl Object for WlFixes {} simple_add_obj!(WlFixes); #[derive(Debug, Error)] pub enum WlFixesError { #[error(transparent)] ClientError(Box), } efrom!(WlFixesError, ClientError);