[−][src]Trait webthing::thing::Thing
High-level Thing trait.
Required methods
fn as_thing_description(&self) -> Map<String, Value>
Return the thing state as a Thing Description.
fn as_any(&self) -> &dyn Any
Return this thing as an Any.
fn as_mut_any(&mut self) -> &mut dyn Any
Return this thing as a mutable Any.
fn get_href(&self) -> String
Get this thing's href.
fn get_href_prefix(&self) -> String
Get this thing's href prefix, i.e. /0.
fn get_ui_href(&self) -> Option<String>
Get the UI href.
fn set_href_prefix(&mut self, prefix: String)
Set the prefix of any hrefs associated with this thing.
fn set_ui_href(&mut self, href: String)
Set the href of this thing's custom UI.
fn get_id(&self) -> String
Get the ID of the thing.
fn get_title(&self) -> String
Get the title of the thing.
fn get_context(&self) -> String
Get the type context of the thing.
fn get_type(&self) -> Vec<String>
Get the type(s) of the thing.
fn get_description(&self) -> String
Get the description of the thing.
fn get_property_descriptions(&self) -> Map<String, Value>
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
Get the thing's actions as an array.
fn get_event_descriptions(&self, event_name: Option<String>) -> Value
Get the thing's events as an array.
fn add_property(&mut self, property: Box<dyn Property>)
Add a property to this thing.
fn remove_property(&mut self, property_name: String)
Remove a property from this thing.
fn find_property(
&mut self,
property_name: &String
) -> Option<&mut Box<dyn Property>>
&mut self,
property_name: &String
) -> Option<&mut Box<dyn Property>>
Find a property by name.
fn get_property(&self, property_name: &String) -> Option<Value>
Get a property's value.
fn get_properties(&self) -> Map<String, Value>
Get a mapping of all properties and their values.
Returns an object of propertyName -> value.
fn has_property(&self, property_name: &String) -> bool
Determine whether or not this thing has a given property.
fn get_action(
&self,
action_name: String,
action_id: String
) -> Option<Arc<RwLock<Box<dyn Action>>>>
&self,
action_name: String,
action_id: String
) -> Option<Arc<RwLock<Box<dyn Action>>>>
Get an action.
fn add_event(&mut self, event: Box<dyn Event>)
Add a new event and notify subscribers.
fn add_available_event(&mut self, name: String, metadata: Map<String, Value>)
Add an available event.
Arguments
name
- name of the eventmetadata
- 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>
&mut self,
action: Arc<RwLock<Box<dyn Action>>>,
input: Option<&Value>
) -> Result<(), &str>
Perform an action on the thing.
Returns the action that was created.
fn remove_action(&mut self, action_name: String, action_id: String) -> bool
Remove an existing action.
Returns a boolean indicating the presence of the action.
fn add_available_action(&mut self, name: String, metadata: Map<String, Value>)
Add an available action.
Arguments
name
- name of the actionmetadata
- action metadata, i.e. type, description, etc., as a JSON map
fn add_subscriber(&mut self, ws_id: String)
fn remove_subscriber(&mut self, ws_id: String)
fn add_event_subscriber(&mut self, name: String, ws_id: String)
Add a new websocket subscriber to an event.
Arguments
name
- name of the eventws_id
- ID of the websocket
fn remove_event_subscriber(&mut self, name: String, ws_id: String)
Remove a websocket subscriber from an event.
Arguments
name
- name of the eventws_id
- ID of the websocket
fn property_notify(&mut self, name: String, value: Value)
Notify all subscribers of a property change.
fn action_notify(&mut self, action: Map<String, Value>)
Notify all subscribers of an action status change.
fn event_notify(&mut self, name: String, event: Map<String, Value>)
Notify all subscribers of an event.
fn start_action(&mut self, name: String, id: String)
Start the specified action.
fn cancel_action(&mut self, name: String, id: String)
Cancel the specified action.
fn finish_action(&mut self, name: String, id: String)
Finish the specified action.
fn drain_queue(&mut self, ws_id: String) -> Vec<Drain<'_, String>>
Provided methods
fn set_property(
&mut self,
property_name: String,
value: Value
) -> Result<(), &'static str>
&mut self,
property_name: String,
value: Value
) -> Result<(), &'static str>
Set a property value.
Implementors
impl Thing for BaseThing
[src]
fn as_thing_description(&self) -> Map<String, Value>
[src]
Return the thing state as a Thing Description.
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.
fn set_ui_href(&mut self, href: String)
[src]
Set the href of this thing's custom UI.
fn get_id(&self) -> String
[src]
Get the ID of the thing.
fn get_title(&self) -> String
[src]
Get the title of the thing.
fn get_context(&self) -> String
[src]
Get the type context of the thing.
fn get_type(&self) -> Vec<String>
[src]
Get the type(s) of the thing.
fn get_description(&self) -> String
[src]
Get the description of the thing.
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.
fn get_event_descriptions(&self, event_name: Option<String>) -> Value
[src]
Get the thing's events as an array.
fn add_property(&mut self, property: Box<dyn Property>)
[src]
Add a property to this thing.
fn remove_property(&mut self, property_name: String)
[src]
Remove a property from this thing.
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.
fn get_property(&self, property_name: &String) -> Option<Value>
[src]
Get a property's value.
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.
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.
fn add_event(&mut self, event: Box<dyn Event>)
[src]
Add a new event and notify subscribers.
fn add_available_event(&mut self, name: String, metadata: Map<String, Value>)
[src]
Add an available event.
Arguments
name
- name of the eventmetadata
- 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.
Returns the action that was created.
fn remove_action(&mut self, action_name: String, action_id: String) -> bool
[src]
Remove an existing 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.
Arguments
name
- name of the actionmetadata
- action metadata, i.e. type, description, etc., as a JSON map
fn add_subscriber(&mut self, ws_id: String)
[src]
fn remove_subscriber(&mut self, ws_id: String)
[src]
fn add_event_subscriber(&mut self, name: String, ws_id: String)
[src]
Add a new websocket subscriber to an event.
Arguments
name
- name of the eventws_id
- ID of the websocket
fn remove_event_subscriber(&mut self, name: String, ws_id: String)
[src]
Remove a websocket subscriber from an event.
Arguments
name
- name of the eventws_id
- ID of the websocket
fn property_notify(&mut self, name: String, value: Value)
[src]
Notify all subscribers of a property change.
fn action_notify(&mut self, action: Map<String, Value>)
[src]
Notify all subscribers of an action status change.
fn event_notify(&mut self, name: String, event: Map<String, Value>)
[src]
Notify all subscribers of an event.
fn start_action(&mut self, name: String, id: String)
[src]
Start the specified action.
fn cancel_action(&mut self, name: String, id: String)
[src]
Cancel the specified action.
fn finish_action(&mut self, name: String, id: String)
[src]
Finish the specified action.