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")]
{
use rsproperties::{init, PropertyConfig};
use std::path::PathBuf;
// Initialize with defaults
rsproperties::init(None);
// Initialize with custom directories
let config = PropertyConfig {
properties_dir: Some(PathBuf::from("/custom/properties")),
socket_dir: Some(PathBuf::from("/custom/socket")),
};
rsproperties::init(config);
// Get a value of the property.
let value = rsproperties::get_with_default("ro.build.version.sdk", "0");
println!("ro.build.version.sdk: {}", value);
// Set a value of the property.
rsproperties::set("test.property", "test.value").unwrap();
}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 value of the property. If the property is not found, it returns an empty string. If an error occurs, it returns Err.
- get_
with_ default - Get a value of the property. If the property is not found, it returns the default value. If an error occurs, it returns the default value.
- get_
with_ result - 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. If an error occurs, it returns Err. It uses socket communication to set the property. Because it is designed for client applications,
- 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.