Struct spaceapi_server::SpaceapiServer [] [src]

pub struct SpaceapiServer {
    // some fields omitted
}

A Space API server instance.

You can create a new instance using the new constructor method by passing it the host, the port, the Status object and a redis connection info object.

The SpaceapiServer includes a web server through Hyper. Simply call the serve method.

Methods

impl SpaceapiServer

fn new<U, T>(socket_addr: U, status: Status, redis_connection_info: T, status_modifiers: Vec<Box<StatusModifier>>) -> Result<SpaceapiServer, SpaceapiServerError> where U: ToSocketAddrs, T: IntoConnectionInfo

fn serve(self) -> HttpResult<Listening>

Start a HTTP server listening on self.host:self.port.

The call returns an HttpResult<Listening> object, see http://ironframework.io/doc/hyper/server/struct.Listening.html for more information.

fn register_sensor(&mut self, template: Box<SensorTemplate>, data_key: String)

Register a new sensor.

The first argument is a api::SensorTemplate instance containing all static data. The second argument specifies how to get the actual sensor value from Redis. And the third argument specifies the data type of the value.