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. JSONThis 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. JSONThis 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. JSONThis 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. JSONThis 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. JSONThis 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. JSONThis 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 | JSONThis 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. JSONThis 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. JSONThis kind is represented by an object with the following fields:
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
|