use {
    crate::{
        object::Version,
        wire::{ZwpLinuxDmabufV1Id, zwp_linux_dmabuf_v1::*},
        wl_usr::{UsrCon, usr_object::UsrObject},
    },
    std::{convert::Infallible, rc::Rc},
};

pub struct UsrZwpLinuxDmabufV1 {
    pub id: ZwpLinuxDmabufV1Id,
    pub con: Rc<UsrCon>,
    pub version: Version,
}

impl ZwpLinuxDmabufV1EventHandler for UsrZwpLinuxDmabufV1 {
    type Error = Infallible;

    fn format(&self, _ev: Format, _slf: &Rc<Self>) -> Result<(), Self::Error> {
        Ok(())
    }

    fn modifier(&self, _ev: Modifier, _slf: &Rc<Self>) -> Result<(), Self::Error> {
        Ok(())
    }
}

usr_object_base! {
    self = UsrZwpLinuxDmabufV1 = ZwpLinuxDmabufV1;
    version = self.version;
}

impl UsrObject for UsrZwpLinuxDmabufV1 {
    fn destroy(&self) {
        self.con.request(Destroy { self_id: self.id })
    }
}
