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 system properties.
- Deserialize system properties.
§Usage
#[cfg(target_os = "android")]
{
// 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
rsproperties::set("test.property", "test.value").unwrap();
// For Android system properties, prefer string format used by the system
rsproperties::set("ro.debuggable", "1").unwrap(); // Not &true
}
Re-exports§
pub use errors::ContextWithLocation;
pub use errors::Error;
pub use errors::Result;
Modules§
Structs§
- Property
Config - Configuration for initializing the property system
- Property
Config Builder - Builder for PropertyConfig with validation
- System
Properties - System properties
It can’t be created directly. Use
system_properties()
orsystem_properties_area()
instead.
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
- 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. Before calling this function, init() must be called. It panics if init() is not called or the system properties cannot be opened.