[−][src]Struct webthing::thing::BaseThing
Basic web thing implementation.
This can easily be used by other things to handle most of the boring work.
Methods
impl BaseThing
[src]
pub fn new(
id: String,
title: String,
type_: Option<Vec<String>>,
description: Option<String>
) -> BaseThing
[src]
id: String,
title: String,
type_: Option<Vec<String>>,
description: Option<String>
) -> BaseThing
Create a new BaseThing.
id -- the thing's unique ID - must be a URI title -- the thing's title type -- the thing's type(s) description -- description of the thing
Trait Implementations
impl Thing for BaseThing
[src]
fn as_thing_description(&self) -> Map<String, Value>
[src]
Return the thing state as a Thing Description.
Returns the state as a JSON map.
fn as_any(&self) -> &dyn Any
[src]
Return this thing as an Any.
fn as_mut_any(&mut self) -> &mut dyn Any
[src]
Return this thing as a mutable Any.
fn get_href(&self) -> String
[src]
Get this thing's href.
fn get_href_prefix(&self) -> String
[src]
Get this thing's href prefix, i.e. /0.
fn get_ui_href(&self) -> Option<String>
[src]
Get the UI href.
fn set_href_prefix(&mut self, prefix: String)
[src]
Set the prefix of any hrefs associated with this thing.
prefix -- the prefix
fn set_ui_href(&mut self, href: String)
[src]
Set the href of this thing's custom UI.
href -- the href
fn get_id(&self) -> String
[src]
Get the ID of the thing.
Returns the ID as a string.
fn get_title(&self) -> String
[src]
Get the title of the thing.
Returns the title as a string.
fn get_context(&self) -> String
[src]
Get the type context of the thing.
Returns the context as a string.
fn get_type(&self) -> Vec<String>
[src]
Get the type(s) of the thing.
Returns the list of types.
fn get_description(&self) -> String
[src]
Get the description of the thing.
Returns the description as a string.
fn get_property_descriptions(&self) -> Map<String, Value>
[src]
Get the thing's properties as a JSON map.
Returns the properties as a JSON map, i.e. name -> description.
fn get_action_descriptions(&self, action_name: Option<String>) -> Value
[src]
Get the thing's actions as an array.
action_name -- Optional action name to get descriptions for
Returns the action descriptions.
fn get_event_descriptions(&self, event_name: Option<String>) -> Value
[src]
Get the thing's events as an array.
event_name -- Optional event name to get descriptions for
Returns the event descriptions.
fn add_property(&mut self, property: Box<dyn Property>)
[src]
Add a property to this thing.
property -- property to add
fn remove_property(&mut self, property_name: String)
[src]
Remove a property from this thing.
property -- property to remove
fn find_property(
&mut self,
property_name: String
) -> Option<&mut Box<dyn Property>>
[src]
&mut self,
property_name: String
) -> Option<&mut Box<dyn Property>>
Find a property by name.
property_name -- the property to find
Returns a boxed property trait object, if found, else None.
fn get_property(&self, property_name: String) -> Option<Value>
[src]
Get a property's value.
property_name -- the property to get the value of
Returns the properties value, if found, else None.
fn get_properties(&self) -> Map<String, Value>
[src]
Get a mapping of all properties and their values.
Returns an object of propertyName -> value.
fn has_property(&self, property_name: String) -> bool
[src]
Determine whether or not this thing has a given property.
property_name -- the property to look for
Returns a boolean, indicating whether or not the thing has the property.
fn get_action(
&self,
action_name: String,
action_id: String
) -> Option<Arc<RwLock<Box<dyn Action>>>>
[src]
&self,
action_name: String,
action_id: String
) -> Option<Arc<RwLock<Box<dyn Action>>>>
Get an action.
action_name -- name of the action action_id -- ID of the action
Returns the requested action if found, else None.
fn add_event(&mut self, event: Box<dyn Event>)
[src]
Add a new event and notify subscribers.
event -- the event that occurred
fn add_available_event(&mut self, name: String, metadata: Map<String, Value>)
[src]
Add an available event.
name -- name of the event metadata -- event metadata, i.e. type, description, etc., as a JSON map
fn add_action(
&mut self,
action: Arc<RwLock<Box<dyn Action>>>,
input: Option<&Value>
) -> Result<(), &str>
[src]
&mut self,
action: Arc<RwLock<Box<dyn Action>>>,
input: Option<&Value>
) -> Result<(), &str>
Perform an action on the thing.
action_name -- name of the action input_ -- any action inputs
Returns the action that was created.
fn remove_action(&mut self, action_name: String, action_id: String) -> bool
[src]
Remove an existing action.
action_name -- name of the action action_id -- ID of the action
Returns a boolean indicating the presence of the action.
fn add_available_action(&mut self, name: String, metadata: Map<String, Value>)
[src]
Add an available action.
name -- name of the action metadata -- action metadata, i.e. type, description, etc., as a JSON map
fn add_subscriber(&mut self, ws_id: String)
[src]
Add a new websocket subscriber.
ws_id -- ID of the websocket
fn remove_subscriber(&mut self, ws_id: String)
[src]
Remove a websocket subscriber.
ws_id -- ID of the websocket
fn add_event_subscriber(&mut self, name: String, ws_id: String)
[src]
Add a new websocket subscriber to an event.
name -- name of the event ws_id -- ID of the websocket
fn remove_event_subscriber(&mut self, name: String, ws_id: String)
[src]
Remove a websocket subscriber from an event.
name -- name of the event ws_id -- ID of the websocket
fn property_notify(&mut self, name: String, value: Value)
[src]
Notify all subscribers of a property change.
name -- name of the property that changed value -- new property value
fn action_notify(&mut self, action: Map<String, Value>)
[src]
Notify all subscribers of an action status change.
action -- JSON description the action whose status changed
fn event_notify(&mut self, name: String, event: Map<String, Value>)
[src]
Notify all subscribers of an event.
name -- name of the event that occurred event -- JSON description of the event
fn start_action(&mut self, name: String, id: String)
[src]
Start the specified action.
name -- name of the action id -- ID of the action
fn cancel_action(&mut self, name: String, id: String)
[src]
Cancel the specified action.
name -- name of the action id -- ID of the action
fn finish_action(&mut self, name: String, id: String)
[src]
Finish the specified action.
name -- name of the action id -- ID of the action
fn drain_queue(&mut self, ws_id: String) -> Vec<Drain<String>>
[src]
Drain any message queues for the specified weboscket ID.
ws_id -- ID of the websocket
fn set_property(
&mut self,
property_name: String,
value: Value
) -> Result<(), &'static str>
[src]
&mut self,
property_name: String,
value: Value
) -> Result<(), &'static str>
Auto Trait Implementations
impl Send for BaseThing
impl Sync for BaseThing
impl Unpin for BaseThing
impl !UnwindSafe for BaseThing
impl !RefUnwindSafe for BaseThing
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> GetTypeId for T where
T: Any,
[src]
T: Any,