Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document ServiceAdapter and Service. #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion src/controler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down