wayland: make object versions type safe
This commit is contained in:
parent
0d7b45d149
commit
e3a1a0b30f
50 changed files with 198 additions and 173 deletions
|
|
@ -2,6 +2,7 @@ use {
|
|||
crate::{client::ClientError, utils::buffd::MsgParser, wire::WlDisplayId},
|
||||
std::{
|
||||
any::Any,
|
||||
cmp::Ordering,
|
||||
fmt::{Display, Formatter},
|
||||
rc::Rc,
|
||||
},
|
||||
|
|
@ -54,3 +55,22 @@ impl Interface {
|
|||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub struct Version(pub u32);
|
||||
|
||||
impl Version {
|
||||
pub const ALL: Version = Version(0);
|
||||
}
|
||||
|
||||
impl PartialEq<u32> for Version {
|
||||
fn eq(&self, other: &u32) -> bool {
|
||||
self.0 == *other
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd<u32> for Version {
|
||||
fn partial_cmp(&self, other: &u32) -> Option<Ordering> {
|
||||
self.0.partial_cmp(other)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue