Skip to main content

PropertyStore

Struct PropertyStore 

Source
pub struct PropertyStore { /* private fields */ }
Expand description

Per-object property cache.

Building an atomic request means naming properties by id, and resolving a name to an id costs an ioctl per property. Caching once per object turns per-frame property lookup into a hash-map hit.

Implementations§

Source§

impl PropertyStore

Source

pub fn new() -> Self

An empty store.

Source

pub fn cache_properties( &mut self, device: &Device, object_id: u32, object_type: ObjectType, ) -> Result<()>

Query and cache every property of one object, replacing any previous entry for it.

A property whose get_property lookup fails is skipped rather than failing the whole object, matching the C++ continue: one unreadable property should not make a plane unusable.

§Errors

CoreError::NoSuchObject for object id 0. Otherwise, if the object’s property set cannot be read at all, the kernel’s refusal: normally CoreError::Io.

Source

pub fn properties(&self, object_id: u32) -> Option<&[PropertyInfo]>

Every cached property of an object, or None if it was never cached.

Source

pub fn property_id(&self, object_id: u32, name: &str) -> Result<u32>

The id of a named property, for building an atomic request.

§Errors

CoreError::NoSuchObject if the object was never cached, or CoreError::NoSuchProperty if it has no such property. The C++ reports no_such_file_or_directory for both; splitting them says which mistake was made.

Source

pub fn property_value(&self, object_id: u32, name: &str) -> Result<u64>

The cached value of a named property.

§Errors

As PropertyStore::property_id.

Source

pub fn enum_value( &self, device: &Device, object_id: u32, property: &str, variant: &str, ) -> Result<u64>

The raw value of an enum property’s named variant.

Enum properties are named by string in the KMS ABI but written as integers, and the integer a driver assigns to a given name is its own business. Hardcoding one that happened to be right on the card in front of you silently selects a different variant elsewhere – for COLOR_ENCODING that is a wrong YCbCr matrix, which is a visible tint rather than an error.

§Errors

CoreError::NoSuchObject if the object was never cached; CoreError::NoSuchProperty if it has no such property, if it is not an enum, or if it has no variant by that name.

Source

pub fn bitmask_bits( &self, device: &Device, object_id: u32, property: &str, ) -> Result<u64>

The union of the bits a bitmask property advertises.

rotation is the one that matters: it is a bitmask whose enum entries name the DRM_MODE_ROTATE_* and DRM_MODE_REFLECT_* bits the plane actually implements, and a plane can expose the property while implementing only 0/180 or a reflect. A caller that treats the property’s presence as “can rotate” and asks for 90 degrees gets a driver that silently drops the request, so the layer comes out the wrong way round with every ioctl succeeding.

The drm crate reports a bitmask property as ValueType::Bitmask with no payload – it parses the enum table only for ValueType::Enum – so this reads the property directly.

§Errors

CoreError::NoSuchObject if the object was never cached; CoreError::NoSuchProperty if it has no such property or it is not a bitmask.

Source

pub fn is_immutable(&self, object_id: u32, name: &str) -> Result<bool>

Whether a named property is DRM_MODE_PROP_IMMUTABLE.

Writing an immutable property in an atomic commit is rejected with EINVAL whatever the value, so a request builder must skip it.

§Errors

As PropertyStore::property_id.

Source

pub fn range(&self, object_id: u32, name: &str) -> Result<Option<(u64, u64)>>

The inclusive (min, max) of a named unsigned range property.

None when the property is not an unsigned range – see PropertyInfo::range – which callers treat as “no bound to enforce” rather than an error.

§Errors

As PropertyStore::property_id.

Source

pub fn clear(&mut self)

Drop everything cached.

Source

pub fn forget(&mut self, object_id: u32)

Drop the cache for one object, for instance after a hotplug.

Source

pub fn len(&self) -> usize

How many objects are cached.

Source

pub fn is_empty(&self) -> bool

Whether nothing is cached.

Trait Implementations§

Source§

impl Clone for PropertyStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PropertyStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PropertyStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.