new_client

Function new_client 

Source
pub fn new_client(
    project_api_url: &str,
    username: &str,
    password: &str,
) -> Result<SkySparkClient, Box<dyn Error>>
Expand description

A shortcut function to quickly create a SkySparkClient.

ยงExample

let mut client = raystack_blocking::new_client(
    "https://skyspark.company.com/api/bigProject/",
    "username",
    "p4ssw0rd"
);
Examples found in repository?
examples/quick_client.rs (line 6)
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}