SkySparkClient

Struct SkySparkClient 

Source
pub struct SkySparkClient { /* private fields */ }
Expand description

A client for interacting with a SkySpark server.

Implementations§

Source§

impl SkySparkClient

Source

pub fn new( project_api_url: Url, username: &str, password: &str, ) -> Result<Self, NewSkySparkClientError>

Create a new SkySparkClient.

§Example
use raystack_blocking::SkySparkClient;
use url::Url;
let url = Url::parse("https://skyspark.company.com/api/bigProject/").unwrap();
let mut client = SkySparkClient::new(url, "username", "p4ssw0rd").unwrap();
Examples found in repository?
examples/client.rs (line 16)
7fn main() -> Result<(), Box<dyn Error>> {
8    use raystack_blocking::{SkySparkClient, ValueExt};
9    use url::Url;
10
11    let url = Url::parse("https://www.example.com/api/projName/")?;
12
13    // If you are going to create many `SkySparkClient`s,
14    // reuse the same `reqwest::Client` in each `SkySparkClient`
15    // by using the `SkySparkClient::new_with_client` function instead.
16    let mut client = SkySparkClient::new(url, "username", "p4ssw0rd")?;
17
18    let sites_grid = client.eval("readAll(site)")?;
19
20    // Print the raw JSON:
21    println!("{}", sites_grid.to_json_string_pretty());
22
23    // Working with the Grid struct:
24    println!("All columns: {:?}", sites_grid.cols());
25    println!(
26        "first site id: {:?}",
27        sites_grid.rows()[0]["id"].as_hs_ref().unwrap()
28    );
29
30    Ok(())
31}
Source

pub fn new_with_runtime( project_api_url: Url, username: &str, password: &str, rt: Arc<Runtime>, ) -> Result<Self, NewSkySparkClientError>

Create a new SkySparkClient using an existing Tokio runtime.

Source

pub fn project_name(&self) -> &str

Return the project name for this client.

Source

pub fn project_api_url(&self) -> &Url

Return the project API url being used by this client.

Source§

impl SkySparkClient

Source

pub fn about(&mut self) -> Result<Grid, Error>

Returns a grid containing basic server information.

Source

pub fn filetypes(&mut self) -> Result<Grid, Error>

Returns a grid describing what MIME types are available.

Source

pub fn his_read( &mut self, id: &Ref, range: &HisReadRange, ) -> Result<Grid, Error>

Returns a grid of history data for a single point.

Source

pub fn his_write_bool( &mut self, id: &Ref, his_data: &[(DateTime, bool)], ) -> Result<Grid, Error>

Writes boolean values to a single point.

Source

pub fn his_write_num( &mut self, id: &Ref, his_data: &[(DateTime, Number)], ) -> Result<Grid, Error>

Writes numeric values to a single point. unit must be a valid Haystack unit literal, such as L/s or celsius.

Source

pub fn his_write_str( &mut self, id: &Ref, his_data: &[(DateTime, String)], ) -> Result<Grid, Error>

Writes string values to a single point.

Source

pub fn utc_his_write_bool( &mut self, id: &Ref, time_zone_name: &str, his_data: &[(DateTime<Utc>, bool)], ) -> Result<Grid, Error>

Writes boolean values with UTC timestamps to a single point. time_zone_name must be a valid SkySpark timezone name.

Source

pub fn utc_his_write_num( &mut self, id: &Ref, time_zone_name: &str, his_data: &[(DateTime<Utc>, Number)], ) -> Result<Grid, Error>

Writes numeric values with UTC timestamps to a single point. unit must be a valid Haystack unit literal, such as L/s or celsius. time_zone_name must be a valid SkySpark timezone name.

Source

pub fn utc_his_write_str( &mut self, id: &Ref, time_zone_name: &str, his_data: &[(DateTime<Utc>, String)], ) -> Result<Grid, Error>

Writes string values with UTC timestamps to a single point. time_zone_name must be a valid SkySpark timezone name.

Source

pub fn nav(&mut self, nav_id: Option<&Ref>) -> Result<Grid, Error>

The Haystack nav operation.

Source

pub fn ops(&mut self) -> Result<Grid, Error>

Returns a grid containing the operations available on the server.

Source

pub fn read(&mut self, filter: &str, limit: Option<u64>) -> Result<Grid, Error>

Returns a grid containing the records matching the given Axon filter string.

Source

pub fn read_by_ids(&mut self, ids: &[Ref]) -> Result<Grid, Error>

Returns a grid containing the records matching the given id Refs.

Source§

impl SkySparkClient

Source

pub fn eval(&mut self, axon_expr: &str) -> Result<Grid, Error>

Examples found in repository?
examples/quick_client.rs (line 8)
3fn main() -> Result<(), Box<dyn Error>> {
4    use raystack_blocking::{new_client, ValueExt};
5
6    let mut client = new_client("https://www.example.com/api/projName/", "username", "p4ssw0rd")?;
7
8    let sites_grid = client.eval("readAll(site)")?;
9
10    // Print the raw JSON:
11    println!("{}", sites_grid.to_json_string_pretty());
12
13    // Working with the Grid struct:
14    println!("All columns: {:?}", sites_grid.cols());
15    println!(
16        "first site id: {:?}",
17        sites_grid.rows()[0]["id"].as_hs_ref().unwrap()
18    );
19
20    Ok(())
21}
More examples
Hide additional examples
examples/client.rs (line 18)
7fn main() -> Result<(), Box<dyn Error>> {
8    use raystack_blocking::{SkySparkClient, ValueExt};
9    use url::Url;
10
11    let url = Url::parse("https://www.example.com/api/projName/")?;
12
13    // If you are going to create many `SkySparkClient`s,
14    // reuse the same `reqwest::Client` in each `SkySparkClient`
15    // by using the `SkySparkClient::new_with_client` function instead.
16    let mut client = SkySparkClient::new(url, "username", "p4ssw0rd")?;
17
18    let sites_grid = client.eval("readAll(site)")?;
19
20    // Print the raw JSON:
21    println!("{}", sites_grid.to_json_string_pretty());
22
23    // Working with the Grid struct:
24    println!("All columns: {:?}", sites_grid.cols());
25    println!(
26        "first site id: {:?}",
27        sites_grid.rows()[0]["id"].as_hs_ref().unwrap()
28    );
29
30    Ok(())
31}

Trait Implementations§

Source§

impl Debug for SkySparkClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more