[][src]Crate raystack

Overview

This crate provides functions which can query a SkySpark server, using the Haystack REST API and the SkySpark REST API's eval operation. Some Haystack operations are not implemented (watch* operations, pointWrite and invokeAction).

Usage

  1. Create a new rust project: cargo new --bin my_project
  2. Put these dependencies in your Cargo.toml:
    [dependencies]
    chrono = "0.4.7"
    chrono-tz = "0.5.1"
    raystack = "0.1.0"
    serde_json = "1.0.40"
    url = "1.7.2"
    
  3. Put this in main.rs to create and use a SkySparkClient:
    use raystack::{HaystackRest, SkySparkClient, SkySparkRest};
    use url::Url;
     
    fn main() {
        let url = Url::parse("https://www.example.com/api/projName/").unwrap();
        let client = SkySparkClient::new(url, "username", "p4ssw0rd").unwrap();
        let sites_grid = client.eval("readAll(site)").unwrap();
     
        // Print the raw JSON:
        println!("{}", sites_grid.to_string_pretty());
     
        // Working with the Grid struct:
        println!("All columns: {:?}", sites_grid.cols());
        println!("first site id: {:?}", sites_grid.rows()[0]["id"].as_str().unwrap());
    }

The Grid struct is a wrapper around the underlying JSON Value enum provided by the serde_json crate. See the documentation for Value for more information on how to query for data stored within it.

Structs

Error

Encapsulates all errors that can occur in this crate.

Grid

A wrapper around a serde_json::Value which represents a Haystack Grid. Columns will be sorted.

ParseJsonGridError

Error denoting that a JSON value could not be parsed into a Grid.

ParseRefError

An error indicating that a Ref could not be parsed.

Ref

A Haystack Ref.

SkySparkClient

A client for interacting with a SkySpark server.

Enums

HisReadRange

Represents the different time range queries that can be sent as part of the hisRead Haystack operation.

Traits

HaystackRest

Provides functions which correspond to some Haystack REST API operations.

SkySparkRest

Provides functions which correspond to some SkySpark REST API operations.