api: remove ::dummy from Id types

`::dummy` was used for testing purposes and became redundant after
adding e.g. `from_raw` and `into_raw` methods on `Id` types.
This commit is contained in:
daxpedda 2024-09-29 15:49:45 +02:00 committed by GitHub
parent 6e1b9fa24d
commit 32cd1ad9a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 219 additions and 352 deletions

View file

@ -1,13 +1,16 @@
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct DeviceId(i32);
#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct DeviceId(u32);
impl DeviceId {
pub fn new(pointer_id: i32) -> Self {
Self(pointer_id)
}
pub const fn dummy() -> Self {
Self(-1)
pub fn new(pointer_id: i32) -> Option<Self> {
if let Ok(pointer_id) = u32::try_from(pointer_id) {
Some(Self(pointer_id))
} else if pointer_id == -1 {
None
} else {
tracing::error!("found unexpected negative `PointerEvent.pointerId`: {pointer_id}");
None
}
}
}
@ -22,6 +25,7 @@ impl FingerId {
Self { pointer_id, primary }
}
#[cfg(test)]
pub const fn dummy() -> Self {
Self { pointer_id: -1, primary: false }
}