[−][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).
Example Usage
Put this in the main function in the main.rs
file to create
and use a SkySparkClient
:
use raystack::{ClientSeed, SkySparkClient, ValueExt}; use url::Url; let timeout_in_seconds = 30; let client_seed = ClientSeed::new(timeout_in_seconds).unwrap(); let url = Url::parse("https://www.example.com/api/projName/").unwrap(); let client = SkySparkClient::new(url, "username", "p4ssw0rd", client_seed).await.unwrap(); let sites_grid = client.eval("readAll(site)").await.unwrap(); // Print the raw JSON: println!("{}", sites_grid.to_json_string_pretty()); // Working with the Grid struct: println!("All columns: {:?}", sites_grid.cols()); println!("first site id: {:?}", sites_grid.rows()[0]["id"].as_hs_ref().unwrap());
See the examples
folder for more usage examples.
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.
Additional functions for extracting Haystack values from the underlying
JSON are found in this crate's ValueExt
trait.
Modules
auth |
Structs
ClientSeed | Contains resources used by a |
Coord | A Haystack Coord, representing a geographical coordinate. |
Grid | A wrapper around a |
NewClientSeedError | Errors that can occur when creating a new |
Number | A Haystack Number, encapsulating a scalar value and an optional unit value. The unit is represented as a string. |
ParseJsonGridError | Error denoting that a JSON value could not be parsed into a |
ParseNumberError | Error denoting that a |
ParseRefError | An error indicating that a |
ParseTagNameError | An error indicating that a |
Ref | A Haystack Ref. |
SkySparkClient | A client for interacting with a SkySpark server. |
TagName | A Haystack tag name. |
Enums
Error | Describes the kinds of errors that can occur in this crate. |
HisReadRange | Represents the different time range queries that can be sent
as part of the |
NewSkySparkClientError | Errors that can occur when creating a new |
Traits
ValueExt | An extension trait for the |
Functions
is_tag_name | Return true if the string is a valid tag name. |