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

pub struct UsrZwpLinuxBufferParamsV1 {
    pub id: ZwpLinuxBufferParamsV1Id,
    pub con: Rc<UsrCon>,
    pub version: Version,
}

impl ZwpLinuxBufferParamsV1EventHandler for UsrZwpLinuxBufferParamsV1 {
    type Error = Infallible;

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

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

usr_object_base! {
    self = UsrZwpLinuxBufferParamsV1 = ZwpLinuxBufferParamsV1;
    version = self.version;
}

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