[][src]Struct webthing::thing::BaseThing

pub struct BaseThing { /* fields omitted */ }

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]

Create a new BaseThing.

Arguments

  • 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 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]

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]

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]

Add an available event.

Arguments

  • name - name of the event
  • metadata - 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]

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]

Add an available action.

Arguments

  • name - name of the action
  • metadata - action metadata, i.e. type, description, etc., as a JSON map

pub fn add_subscriber(&mut self, ws_id: String)[src]

Add a new websocket subscriber.

Arguments

  • ws_id - ID of the websocket

pub fn remove_subscriber(&mut self, ws_id: String)[src]

Remove a websocket subscriber.

Arguments

  • ws_id - ID of the websocket

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 event
  • ws_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 event
  • ws_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]

Drain any message queues for the specified weboscket ID.

Arguments

  • ws_id - ID of the websocket

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T> GetTypeId for T where
    T: Any
[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,