Struct webthing::property::BaseProperty
source · pub struct BaseProperty { /* private fields */ }
Expand description
Basic property implementation.
A Property represents an individual state value of a thing.
This can easily be used by other properties to handle most of the boring work.
Implementations
sourceimpl BaseProperty
impl BaseProperty
sourcepub fn new(
name: String,
initial_value: Value,
value_forwarder: Option<Box<dyn ValueForwarder>>,
metadata: Option<Map<String, Value>>
) -> BaseProperty
pub fn new(
name: String,
initial_value: Value,
value_forwarder: Option<Box<dyn ValueForwarder>>,
metadata: Option<Map<String, Value>>
) -> BaseProperty
Create a new BaseProperty.
name – name of the property initial_value – initial property value value_forwarder – optional value forwarder; property will be read-only if None metadata – property metadata, i.e. type, description, unit, etc., as a JSON map
Trait Implementations
sourceimpl Property for BaseProperty
impl Property for BaseProperty
sourcefn set_href_prefix(&mut self, prefix: String)
fn set_href_prefix(&mut self, prefix: String)
Set the prefix of any hrefs associated with this property.
prefix – the prefix
sourcefn set_value(&mut self, value: Value) -> Result<(), &'static str>
fn set_value(&mut self, value: Value) -> Result<(), &'static str>
Set the current value of the property.
value – the value to set
sourcefn set_cached_value(&mut self, value: Value) -> Result<(), &'static str>
fn set_cached_value(&mut self, value: Value) -> Result<(), &'static str>
Set the cached value of the property.
value – the value to set
sourcefn get_metadata(&self) -> Map<String, Value>
fn get_metadata(&self) -> Map<String, Value>
Get the metadata associated with this property.
Auto Trait Implementations
impl !RefUnwindSafe for BaseProperty
impl Send for BaseProperty
impl Sync for BaseProperty
impl Unpin for BaseProperty
impl !UnwindSafe for BaseProperty
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more