Crates.io | iron_planet |
lib.rs | iron_planet |
version | 0.2.2 |
source | src |
created_at | 2021-11-13 09:37:36.281088 |
updated_at | 2021-11-14 14:44:52.373553 |
description | Supernova platform client |
homepage | https://supernova.nunl.pt |
repository | https://gitlab.com/nunl/supernova_client_rust |
max_upload_size | |
id | 481331 |
size | 123,298 |
A client library for the Supernova REST API.
use iron_planet::{Supernova, RequestConfig};
fn main() {
// Instantiate an unprivileged client
let sn = Supernova::new();
let conf = RequestConfig::default();
// One can use it to query endpoints that require no auth
let result = sn.get_buildings(&conf); // Will succeed, hopefully
// But not to query endpoints that require user auth
let result = sn.get_class_inst(123, &conf); // Will fail, hopefully
// It is possible to enable authentication in two different ways
// One can provide authentication credentials in the form of a user-pass
// A successful login will return a result with the session token
let token = sn.login("user", "pass").unwrap();
sn.logout();
// The second one is to provide an existing token
sn.set_auth_token(token);
}
warmup()
upon instantiation to eagerly load the buildings, courses, classes, departments and places.
This might be desirable to speed up subsequent access in exchange for a startup penalty (between 5 and 15 seconds).get_[collection]
functions independently.