pub struct SystemProperties { /* private fields */ }Expand description
System properties
It can’t be created directly. Use system_properties() or system_properties_area() instead.
Implementations§
Source§impl SystemProperties
impl SystemProperties
Sourcepub fn read_with<R, F>(&self, name: &str, f: F) -> Result<R>
pub fn read_with<R, F>(&self, name: &str, f: F) -> Result<R>
Reads name’s value and passes it to f as &str without ever
materialising an owned String. Intended for the parse-and-discard
hot path (get<T>, get_or<T>) where the caller does not need
ownership of the value bytes.
Mirrors bionic’s __system_property_read_callback pattern. The
callback runs while the seqlock-validated bytes are still borrowed
(from buf for short properties, from the mmap for long ones), so
it should be cheap and non-blocking.
Sourcepub fn get_with_result(&self, name: &str) -> Result<String>
pub fn get_with_result(&self, name: &str) -> Result<String>
Get property value that returns error for missing properties.
Allocates a String; for the parse-and-discard hot path prefer
Self::read_with, which hands the value as &str without
allocating.
Sourcepub fn find(&self, name: &str) -> Result<Option<PropertyIndex>>
pub fn find(&self, name: &str) -> Result<Option<PropertyIndex>>
Get the property index of a system property by name. The property index is used to update the property value. If the property is not found, it returns Ok(None)
pub fn context_serial(&self) -> u32
Sourcepub fn serial(&self, idx: &PropertyIndex) -> Option<u32>
pub fn serial(&self, idx: &PropertyIndex) -> Option<u32>
Reads the per-property serial counter, or None if the context/property
lookup fails. 0 is a valid initial serial, so callers cannot use a
numeric sentinel — use the Option to distinguish absence.