Crate hub_sdk [] [src]

Geeny Hub SDK

Introduction

The Geeny Hub SDK provides an abstraction over APIs and communication interfaces necessary to connect physical or virtual devices to the Geeny cloud. The Hub SDK can be used in one of two ways: as a Rust library crate, or as a a standalone binary that can be used by applications written in other languages by providing an interprocess communication interface.

For developers with an existing Hub Device, such as a Smart Home Gateway, the standalone Geeny Hub Service may be used to provide a single local interface to communicate with Geeny Cloud Services to enable device provisioning, sending messages to the cloud, and receiving messages from the cloud. The Geeny Hub Service may be installed as a package, or included as part of a firmware generation process such as Buildroot or Yocto. When used as a service, no knowledge of Rust developement is necessary.

For developers building a new Hub Device, the Geeny Hub SDK may be used as a library (or crate), and can be tightly integrated into a Rust-based application. This allows developers to interact with the Geeny Cloud through an idiomatic Rust library interface, rather than having to implement REST, MQTT, and other communication protocols.

Components

Usage - As a Library Crate

extern crate hub_sdk;

use hub_sdk::{HubSDK, HubSDKConfig};

fn main() {
    let sdk_cfg = HubSDKConfig::default();

    // Begin running the SDK. The hub_sdk handle may be used to interact with
    // the sdk. This handle may be cloned and given to multiple consumers
    let hub_sdk = HubSDK::new(sdk_cfg);

    let msgs = hub_sdk.receive_messages("ABC123")
        .expect("No known device with that serial number");

    println!("Messages: {:?}", msgs);
}

Documentation

Full library documentation may be found on docs.rs, or may be generated from this repository using cargo doc --open.

Usage - As a standalone service

# Create a valid config file for this service
cp ./geeny_hub_service.mvdb.json.example ./geeny_hub_service.mvdb.json

# Run the service, serving a REST IPC on localhost:9000
cargo run --release --bin hub-service

Documentation

For more information regarding the REST IPC interface, please see this Swagger API specification for more information.

Requirements

Currently, the Geeny Hub SDK requires a nightly build of Rust.

Installation & Configuration

As a library

In your Cargo.toml, add the following lines:

[dependencies]
hub-sdk = "0.4"

In your main project file (likely lib.rs or main.rs), add the following line:

This example is not tested
extern crate hub_sdk;

As a service

# Create a valid config file for this service
cp ./geeny_hub_service.mvdb.json.example ./geeny_hub_service.mvdb.json

# Run the service, serving a REST IPC on localhost:9000
cargo run --release --bin hub-service --features="rest-service"

Testing

Unit tests may be run with cargo test.

License

Copyright (C) 2017 Telefónica Germany Next GmbH, Charlottenstrasse 4, 10969 Berlin.

This project is licensed under the terms of the Mozilla Public License Version 2.0.

Contact: devsupport@geeny.io

Re-exports

pub extern crate geeny_api;

Modules

errors

Geeny Hub SDK Error Types

services

Hub SDK Services - Service Applications using the Geeny Hub SDK

Structs

HubSDK

Interface handle for a HubSDK instance

HubSDKConfig

Configuration structure for a HubSDK instance