pub struct PropertyGuard<'fwnode, 'name, T> { /* private fields */ }
Expand description
A helper for reading device properties.
Use Self::required_by
if a missing property is considered a bug and
Self::optional
otherwise.
For convenience, Self::or
and Self::or_default
are provided.
Implementations§
Source§impl<T> PropertyGuard<'_, '_, T>
impl<T> PropertyGuard<'_, '_, T>
Sourcepub fn required_by(self, dev: &Device) -> Result<T>
pub fn required_by(self, dev: &Device) -> Result<T>
Access the property, indicating it is required.
If the property is not present, the error is automatically logged. If a
missing property is not an error, use Self::optional
instead. The
device is required to associate the log with it.
Sourcepub fn optional(self) -> Option<T>
pub fn optional(self) -> Option<T>
Access the property, indicating it is optional.
In contrast to Self::required_by
, no error message is logged if
the property is not present.
Sourcepub fn or(self, default: T) -> T
pub fn or(self, default: T) -> T
Access the property or the specified default value.
Do not pass a sentinel value as default to detect a missing property.
Use Self::required_by
or Self::optional
instead.
Source§impl<T: Default> PropertyGuard<'_, '_, T>
impl<T: Default> PropertyGuard<'_, '_, T>
Sourcepub fn or_default(self) -> T
pub fn or_default(self) -> T
Access the property or a default value.
Use Self::or
to specify a custom default value.
Auto Trait Implementations§
impl<'fwnode, 'name, T> Freeze for PropertyGuard<'fwnode, 'name, T>where
T: Freeze,
impl<'fwnode, 'name, T> !RefUnwindSafe for PropertyGuard<'fwnode, 'name, T>
impl<'fwnode, 'name, T> !Send for PropertyGuard<'fwnode, 'name, T>
impl<'fwnode, 'name, T> !Sync for PropertyGuard<'fwnode, 'name, T>
impl<'fwnode, 'name, T> Unpin for PropertyGuard<'fwnode, 'name, T>where
T: Unpin,
impl<'fwnode, 'name, T> !UnwindSafe for PropertyGuard<'fwnode, 'name, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot
. Read more