Expand description
§Android System Properties for Linux and Android both.
This crate provides a way to access system properties on Linux and Android.
§Features
- Get system properties.
- Set system properties.
- Wait for system properties.
- Serialize/deserialize the property-info trie (requires the
builderfeature).
§Usage
// Get a value of the property.
let value: String = rsproperties::get_or("ro.build.version.sdk", "0".to_owned());
println!("ro.build.version.sdk: {}", value);
// Set a value of the property - use string literals for compatibility
// with values other Android components write (e.g. "1", not "true").
rsproperties::set("test.property", "test.value").unwrap();Re-exports§
pub use errors::ContextWithLocation;pub use errors::Error;pub use errors::Result;pub use wire::PROP_VALUE_MAX;
Modules§
Structs§
- Property
Config - Configuration for initializing the property system
- Property
Config Builder - Builder for
PropertyConfig. Collects optional directories;build()is infallible — andtry_initonly claims the first-write-wins slots. Paths are actually validated at first use (first property access / first socket connection), so a nonexistent directory is not reported until then. - System
Properties - System properties
It can’t be created directly. Use
system_properties()orsystem_properties_area()instead. - Timespec
- Timeout type accepted by
SystemProperties::wait, re-exported so callers don’t need a direct dependency on the exactrustixversion this crate was built against.struct timespec—A quantity of time in seconds plus nanoseconds.
Constants§
Functions§
- get
- Get a property value parsed to specified type Returns Err if property not found, system error, or parse error occurs
- get_or
- Get a property value with default fallback Never fails - always returns a valid value
- get_
or_ else - Like
get_or, but the default is produced lazily — the closure runs only when the property is missing, empty, fails to parse, or the global property store failed to initialize (seetry_system_properties: failure is latched), so the found-and-parsed hot path never pays for constructing it. - init
- Initialize system properties with flexible configuration options.
- properties_
dir - Get the system properties directory. Returns the configured directory if init() was called, otherwise returns the default PROP_DIRNAME (/dev/properties).
- set
- Set a value of the property with any Display type.
- socket_
dir - Get the current socket directory. Returns the configured socket directory, environment variable, or default.
- system_
properties - Get the system properties.
- try_
init - Initialize system properties, returning an error when an option cannot be
applied — typically because it was already set, either explicitly by a
previous
init()/try_init()or implicitly by the first property read (properties_dir()latches the default directory on first use). - try_
system_ properties - Get the system properties, returning an error if initialization fails.