Struct cvar::Property [] [src]

pub struct Property<N, D, T, V, F> where
    N: Borrow<str>,
    D: Borrow<str>,
    T: Value,
    V: Variable<T>,
    F: OnChange<T>, 
{ /* fields omitted */ }

Property instance.

The Name and Description types allow abstracting over &'static str, &'a str and String. This supports dynamic cvars while only paying for what you need.

The Variable type holds a value of the underlying Type with interior mutability.

F is the callable type called when the value is changed.

Methods

impl<N, D, T, V> Property<N, D, T, V, Pass> where
    N: Borrow<str>,
    D: Borrow<str>,
    T: Value,
    V: Variable<T>, 
[src]

Creates a new Property.

Given a name, description, variable and default.

// The underlying data wrapped in a `Cell`.
use std::cell::Cell;
let var = Cell::new(13);

// The variable wrapped in a `Property`.
use cvar::{Property, IProperty};
let prop = Property::new("prop", "property description", &var, 42);
assert_eq!(prop.get(), "13");
prop.reset();
assert_eq!(var.get(), 42);

impl<N, D, T, V> Property<N, D, T, V, Pass> where
    N: Borrow<str>,
    D: Borrow<str>,
    T: Value,
    V: Variable<T>, 
[src]

Creates a new Property with change callback.

Called when a new value is assigned to the property through the set and reset methods. It does not monitor the Volder for changes.

The default value must always validate successfully or reset will panic.

Trait Implementations

impl<N, D, T, V, F> INode for Property<N, D, T, V, F> where
    N: Borrow<str>,
    D: Borrow<str>,
    T: Value,
    V: Variable<T>,
    F: OnChange<T>, 
[src]

Returns the node name.

Returns the node description.

impl<N, D, T, V, F> IProperty for Property<N, D, T, V, F> where
    N: Borrow<str>,
    D: Borrow<str>,
    T: Value,
    V: Variable<T>,
    F: OnChange<T>, 
[src]

Gets the value as a string.

Sets the value. Read more

Resets the value to its default.

Gets the default value as a string.

Returns the state of the property.