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

errors

Structs§

PropertyConfig
Configuration for initializing the property system
PropertyConfigBuilder
Builder for PropertyConfig with validation
SystemProperties
System properties It can’t be created directly. Use system_properties() or system_properties_area() instead.

Constants§

PROPERTY_SERVICE_FOR_SYSTEM_SOCKET_NAME
PROPERTY_SERVICE_SOCKET_NAME
PROP_DIRNAME
PROP_VALUE_MAX

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.