Enum foxbox_taxonomy::services::ChannelKind [] [src]

pub enum ChannelKind {
    Ready,
    OnOff,
    OpenClosed,
    CurrentTime,
    CurrentTimeOfDay,
    RemainingTime,
    OvenTemperature,
    AddThinkerbellRule,
    RemoveThinkerbellRule,
    ThinkerbellRuleSource,
    TakeSnapshot,
    Extension {
        vendor: Id<VendorId>,
        adapter: Id<AdapterId>,
        kind: Id<KindId>,
        typ: Type,
    },
}

The kind of the channel, i.e. a strongly-typed description of what the channel can do. Used both for locating channels (e.g. "I need a clock" or "I need something that can provide pictures") and for determining the data structure that these channel can provide or consume.

A number of channel kinds are standardized, and provided as a set of strongly-typed enum constructors. It is clear, however, that many devices will offer channels that cannot be described by pre-existing constructors. For this purpose, this enumeration offers a constructor Extension, designed to describe novel channels.

JSON

With the exception of the Extension kind, of all variants are represented by a string with their name, e.g.

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let parsed = ChannelKind::from_str("\"Ready\"").unwrap();
assert_eq!(parsed, ChannelKind::Ready);

Variants

Ready

The service is ready. Used for instance once a countdown has reached completion.

JSON

This kind is represented by string "Ready".

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let parsed = ChannelKind::from_str("\"Ready\"").unwrap();
assert_eq!(parsed, ChannelKind::Ready);
OnOff

The service is used to detect or decide whether some device is on or off.

JSON

This kind is represented by string "OnOff".

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let parsed = ChannelKind::from_str("\"OnOff\"").unwrap();
assert_eq!(parsed, ChannelKind::OnOff);
OpenClosed

The service is used to detect or decide whether some device is open or closed.

JSON

This kind is represented by string "OpenClosed".

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let parsed = ChannelKind::from_str("\"OpenClosed\"").unwrap();
assert_eq!(parsed, ChannelKind::OpenClosed);
CurrentTime

The service is used to read or set the current absolute time. Used for instance to wait until a specific time and day before triggering an action, or to set the appropriate time on a new device.

JSON

This kind is represented by string "CurrentTime".

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let parsed = ChannelKind::from_str("\"CurrentTime\"").unwrap();
assert_eq!(parsed, ChannelKind::CurrentTime);
CurrentTimeOfDay

The service is used to read or set the current time of day. Used for instance to trigger an action at a specific hour every day.

JSON

This kind is represented by string "CurrentTimeOfDay".

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let parsed = ChannelKind::from_str("\"CurrentTimeOfDay\"").unwrap();
assert_eq!(parsed, ChannelKind::CurrentTimeOfDay);
RemainingTime

The service is part of a countdown. This is the time remaining until the countdown is elapsed.

JSON

This kind is represented by string "RemainingTime".

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let parsed = ChannelKind::from_str("\"RemainingTime\"").unwrap();
assert_eq!(parsed, ChannelKind::RemainingTime);
OvenTemperature

JSON

This kind is represented by string "OvenTemperature".

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;

let parsed = ChannelKind::from_str("\"OvenTemperature\"").unwrap();
assert_eq!(parsed, ChannelKind::OvenTemperature);
AddThinkerbellRule
RemoveThinkerbellRule
ThinkerbellRuleSource
TakeSnapshot

Capture a new snapshot.

JSON

This kind is represented by string "TakeSnapshot".

use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;
use foxbox_taxonomy::serialize::*;

let source = r#""TakeSnapshot""#;

let parsed = ChannelKind::from_str(source).unwrap();
assert_eq!(parsed, ChannelKind::TakeSnapshot);

let serialized = parsed.to_json(&mut MultiPart::new());
assert_eq!(serialized.as_string().unwrap(), "TakeSnapshot");
Extension

An operation of a kind that has not been standardized yet.

JSON

This kind is represented by an object with the following fields:

  • string vendor
  • string adapter
  • string kind
  • string type (see Type)
use foxbox_taxonomy::services::*;
use foxbox_taxonomy::parse::*;
use foxbox_taxonomy::values::*;

let source = "{
  \"vendor\": \"mozilla.org\",
  \"adapter\": \"foxlink@mozilla.org\",
  \"kind\": \"GroundHumidity\",
  \"type\": \"ExtNumeric\"
}";

let parsed = ChannelKind::from_str(source).unwrap();

if let ChannelKind::Extension { vendor, adapter, kind, typ } = parsed {
  assert_eq!(vendor.to_string(), "mozilla.org");
  assert_eq!(adapter.to_string(), "foxlink@mozilla.org");
  assert_eq!(kind.to_string(), "GroundHumidity");
  assert_eq!(typ, Type::ExtNumeric);
} else {
  panic!()
}

Fields

vendor

The vendor. Used for namespacing purposes, to avoid confusing two incompatible extensions with similar names. For instance, "foxlink@mozilla.com".

adapter

Identification of the adapter introducing this operation. Designed to aid with tracing and debugging.

kind

A string describing the nature of the value, designed to let applications discover the devices.

Examples: "GroundHumidity".

typ

The data type of the value.

Methods

impl ChannelKind

fn get_type(&self) -> Type

Get the type of values used to communicate with this service.

Trait Implementations

impl Deserialize for ChannelKind

fn deserialize<__D>(deserializer: &mut __D) -> Result<ChannelKind, __D::Error> where __D: Deserializer

impl Serialize for ChannelKind

fn serialize<__S>(&self, serializer: &mut __S) -> Result<(), __S::Error> where __S: Serializer

impl Parser<ChannelKind> for ChannelKind

fn description() -> String

fn parse(path: Path, source: &mut JSON) -> Result<Self, ParseError>

fn from_str(source: &str) -> Result<T, ParseError>

fn take(path: Path, source: &mut JSON, field_name: &str) -> Result<T, ParseError>

fn take_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<T, ParseError>>

fn take_vec_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<Vec<T>, ParseError>>

fn take_vec(path: Path, source: &mut JSON, field_name: &str) -> Result<Vec<T>, ParseError>

impl ToJSON for ChannelKind

fn to_json(&self, parts: &mut BinaryParts) -> JSON

Derived Implementations

impl PartialEq for ChannelKind

fn eq(&self, __arg_0: &ChannelKind) -> bool

fn ne(&self, __arg_0: &ChannelKind) -> bool

impl Clone for ChannelKind

fn clone(&self) -> ChannelKind

1.0.0fn clone_from(&mut self, source: &Self)

impl Debug for ChannelKind

fn fmt(&self, __arg_0: &mut Formatter) -> Result