[−][src]Struct webthing::thing::BaseThing
Basic web thing implementation.
This can easily be used by other things to handle most of the boring work.
Implementations
impl BaseThing
[src]
pub fn new(
id: String,
title: String,
type_: Option<Vec<String>>,
description: Option<String>
) -> Self
[src]
id: String,
title: String,
type_: Option<Vec<String>>,
description: Option<String>
) -> Self
Create a new BaseThing.
Arguments
id
- the thing's unique ID - must be a URItitle
- the thing's titletype_
- the thing's type(s)description
- description of the thing
Trait Implementations
impl Default for BaseThing
[src]
impl Thing for BaseThing
[src]
pub fn as_thing_description(&self) -> Map<String, Value>
[src]
Return the thing state as a Thing Description.
pub fn as_any(&self) -> &dyn Any
[src]
Return this thing as an Any.
pub fn as_mut_any(&mut self) -> &mut dyn Any
[src]
Return this thing as a mutable Any.
pub fn get_href(&self) -> String
[src]
Get this thing's href.
pub fn get_href_prefix(&self) -> String
[src]
Get this thing's href prefix, i.e. /0.
pub fn get_ui_href(&self) -> Option<String>
[src]
Get the UI href.
pub fn set_href_prefix(&mut self, prefix: String)
[src]
Set the prefix of any hrefs associated with this thing.
pub fn set_ui_href(&mut self, href: String)
[src]
Set the href of this thing's custom UI.
pub fn get_id(&self) -> String
[src]
Get the ID of the thing.
pub fn get_title(&self) -> String
[src]
Get the title of the thing.
pub fn get_context(&self) -> String
[src]
Get the type context of the thing.
pub fn get_type(&self) -> Vec<String>
[src]
Get the type(s) of the thing.
pub fn get_description(&self) -> String
[src]
Get the description of the thing.
pub 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.
pub fn get_action_descriptions(&self, action_name: Option<String>) -> Value
[src]
Get the thing's actions as an array.
pub fn get_event_descriptions(&self, event_name: Option<String>) -> Value
[src]
Get the thing's events as an array.
pub fn add_property(&mut self, property: Box<dyn Property>)
[src]
Add a property to this thing.
pub fn remove_property(&mut self, property_name: String)
[src]
Remove a property from this thing.
pub 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.
pub fn get_property(&self, property_name: &String) -> Option<Value>
[src]
Get a property's value.
pub fn get_properties(&self) -> Map<String, Value>
[src]
Get a mapping of all properties and their values.
Returns an object of propertyName -> value.
pub fn has_property(&self, property_name: &String) -> bool
[src]
Determine whether or not this thing has a given property.
pub 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.
pub fn add_event(&mut self, event: Box<dyn Event>)
[src]
Add a new event and notify subscribers.
pub fn add_available_event(
&mut self,
name: String,
metadata: Map<String, Value>
)
[src]
&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
pub 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.
pub 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.
pub fn add_available_action(
&mut self,
name: String,
metadata: Map<String, Value>
)
[src]
&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
pub fn add_subscriber(&mut self, ws_id: String)
[src]
pub fn remove_subscriber(&mut self, ws_id: String)
[src]
pub 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
pub 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
pub fn property_notify(&mut self, name: String, value: Value)
[src]
Notify all subscribers of a property change.
pub fn action_notify(&mut self, action: Map<String, Value>)
[src]
Notify all subscribers of an action status change.
pub fn event_notify(&mut self, name: String, event: Map<String, Value>)
[src]
Notify all subscribers of an event.
pub fn start_action(&mut self, name: String, id: String)
[src]
Start the specified action.
pub fn cancel_action(&mut self, name: String, id: String)
[src]
Cancel the specified action.
pub fn finish_action(&mut self, name: String, id: String)
[src]
Finish the specified action.
pub fn drain_queue(&mut self, ws_id: String) -> Vec<Drain<'_, String>>
[src]
pub 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 !RefUnwindSafe for BaseThing
[src]
impl Send for BaseThing
[src]
impl Sync for BaseThing
[src]
impl Unpin for BaseThing
[src]
impl !UnwindSafe for BaseThing
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T> GetTypeId for T where
T: Any,
[src]
T: Any,
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
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.
pub 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,