drm: add ObjectChangeValue
This commit is contained in:
parent
b8d4eeb8e4
commit
e95e764b46
4 changed files with 55 additions and 25 deletions
|
|
@ -1052,9 +1052,9 @@ impl Change {
|
|||
}
|
||||
|
||||
impl<'a> ObjectChange<'a> {
|
||||
pub fn change(&mut self, property_id: DrmProperty, value: u64) {
|
||||
pub fn change(&mut self, property_id: DrmProperty, value: impl ObjectChangeValue) {
|
||||
self.change.props.push(property_id.0);
|
||||
self.change.values.push(value);
|
||||
self.change.values.push(value.into_u64());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1069,6 +1069,36 @@ impl Drop for Change {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait ObjectChangeValue {
|
||||
fn into_u64(self) -> u64;
|
||||
}
|
||||
|
||||
macro_rules! num {
|
||||
($ty:ty) => {
|
||||
impl ObjectChangeValue for $ty {
|
||||
fn into_u64(self) -> u64 {
|
||||
self as u64
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
num!(u16);
|
||||
num!(i32);
|
||||
num!(u32);
|
||||
num!(i64);
|
||||
num!(u64);
|
||||
num!(bool);
|
||||
|
||||
impl<T> ObjectChangeValue for T
|
||||
where
|
||||
T: DrmObject,
|
||||
{
|
||||
fn into_u64(self) -> u64 {
|
||||
self.id() as u64
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(non_camel_case_types)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum ConnectorType {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue