Skip to content

Latest commit

 

History

44 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Semio Client

A library providing Rust bindings to query a Semio Database.

Authentication

All operations rely on a Context, which holds a reqwest::Client. It must be configured with the right token in the HTTP header:

use reqwest::{
  header::{self, HeaderMap, HeaderValue},
  Client, Url,
};

let mut headers = HeaderMap::new();
headers.insert(
  header::AUTHORIZATION,
  HeaderValue::from_str(token.as_str())?,
);
let client = Client::builder().default_headers(headers).build().unwrap();
let context = Context::new(Url::parse("localhost:8080").unwrap(), client);

Credentials and tokens can be saved in a Config object, which can then be serialized into persistent storage. Pay attention to store them into a safe location.

Tokens have a limited lifespan, so it is recommended to refresh them at the beginning of a session by calling access_token(config). It returns a suggested update of the config to apply, as a ConfigMutation. For example:

use semio_client;

let mut config: Config; // load it prior to the following code.
let (token, config_mutation) =
  semio_client::authentication::access_token(&config)
    .await
    .expect("error while refreshing access token");
config = Some(config_mutation.next(config));

Record and query types

The database provides records of type User, Organization, Folder, Enumeration, Structure and Module. Each type of record has a specific set of queries, but some of them are common:

  • get_public: gets the latest record in the database, omitting private information. The record may contain references to versions of its dependencies that must still be resolved.
  • get_private: gets the latest record in the database, including private information. Requires the user to have certain permissions.
  • tagged: gets a frozen record matching the given version tag. The record's references to its dependencies are already resolved, and should correspond to versions existing in the database.
  • tagged_req: gets the latest frozen record matching the given version requirement tag.
  • tags: lists the tags of a record. This can be used to resolve the version tag matching a version requirement.
  • get_frozen: freezes a record on-the-fly, without producing a new tagged record.

Selector

A Selector is an identifier of a record, either in a form of an UUID, or of a dotted path, a String like "my_user.my_folder.my_module" or "my_organization.my_folder.MyStructureType".

About

Rust client library for interacting with the Semio backend

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages