Skip to main content

Crate rsproperties

Crate rsproperties 

Source
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 builder feature).

§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§

errors
wire
Wire-protocol constants and shared validators.

Structs§

PropertyConfig
Configuration for initializing the property system
PropertyConfigBuilder
Builder for PropertyConfig. Collects optional directories; build() is infallible — and try_init only 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.
SystemProperties
System properties It can’t be created directly. Use system_properties() or system_properties_area() instead.
Timespec
Timeout type accepted by SystemProperties::wait, re-exported so callers don’t need a direct dependency on the exact rustix version this crate was built against. struct timespec—A quantity of time in seconds plus nanoseconds.

Constants§

PROPERTY_SERVICE_FOR_SYSTEM_SOCKET_NAME
PROPERTY_SERVICE_SOCKET_NAME
PROP_DIRNAME

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 (see try_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.