From e6da62735d3cc7c73b38afc68958b3b83e9d03a9 Mon Sep 17 00:00:00 2001 From: Marcus Cavanaugh Date: Wed, 3 Feb 2016 14:11:56 +0000 Subject: [PATCH] Document ServiceAdapter and Service. --- src/context.rs | 2 +- src/controler.rs | 2 +- src/service.rs | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/context.rs b/src/context.rs index df366e12..f8ae390d 100644 --- a/src/context.rs +++ b/src/context.rs @@ -13,7 +13,7 @@ use std::net::SocketAddr; use std::net::ToSocketAddrs; use std::sync::{ Arc, Mutex }; -// The `global` context available to all. +/// The `global` context available to all. pub struct Context { pub verbose: bool, diff --git a/src/controler.rs b/src/controler.rs index dcb4f7ee..79228af0 100644 --- a/src/controler.rs +++ b/src/controler.rs @@ -21,7 +21,7 @@ impl Controler { /// /// ``` /// # use service_manager::Controler; - /// let controler = Controller::new(); + /// let controler = Controler::new(); /// ``` pub fn new(sender: EventSender, context: SharedContext) -> Controler { Controler { diff --git a/src/service.rs b/src/service.rs index d84be455..026a7461 100644 --- a/src/service.rs +++ b/src/service.rs @@ -18,6 +18,7 @@ pub struct ServiceProperties { pub ws_url: String } +/// A `Service` represents an individual device. pub trait Service : Send { fn get_properties(&self) -> ServiceProperties; fn start(&self); @@ -33,6 +34,12 @@ impl Serialize for Service { } } +/// A `ServiceAdapter` implements functionality to discover and register a specific type of IoT +/// device protocol. A `ServiceAdapter` can instantiate multiple `Service`s, each representing +/// an individual device. +/// +/// For instance, a `LightBulbAdapter` might instantiate a `LightBulbService` for each light bulb +/// it discovers, registering each with the global `Context`. pub trait ServiceAdapter { fn get_name(&self) -> String; fn start(&self);