Struct AndroidProperty

Source
pub struct AndroidProperty { /* private fields */ }
Expand description

A struct representing android properties

This struct consists from a name-value pair

Implementations§

Source§

impl AndroidProperty

Source

pub fn new(name: &str) -> Self

Initializes and returns struct representing android properties

Examples found in repository?
examples/property_get.rs (line 6)
5fn main() {
6    let mut hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
7    match hello_world.value() {
8        Some(_value) => println!("{}", hello_world),
9        None => println!("Property {} not found", hello_world.name()),
10    };
11}
More examples
Hide additional examples
examples/property_refresh.rs (line 7)
5fn main() {
6    setprop(HELLO_WORLD_PROPERTY, "initial value").expect("Cannot set android property");
7    let hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
8    println!("Initial property: {}", hello_world);
9
10    setprop(HELLO_WORLD_PROPERTY, "refreshed value").expect("Cannot set android property");
11    println!("Refreshed property: {}", hello_world);
12}
Source

pub fn name(&self) -> String

Return property name

Examples found in repository?
examples/property_get.rs (line 9)
5fn main() {
6    let mut hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
7    match hello_world.value() {
8        Some(_value) => println!("{}", hello_world),
9        None => println!("Property {} not found", hello_world.name()),
10    };
11}
Source

pub fn value(&mut self) -> Option<String>

Return property value

Examples found in repository?
examples/property_get.rs (line 7)
5fn main() {
6    let mut hello_world = AndroidProperty::new(HELLO_WORLD_PROPERTY);
7    match hello_world.value() {
8        Some(_value) => println!("{}", hello_world),
9        None => println!("Property {} not found", hello_world.name()),
10    };
11}
Source

pub fn set_value(&self, value: &str) -> Result<(), String>

Set property value

Trait Implementations§

Source§

impl Debug for AndroidProperty

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for AndroidProperty

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.