7 releases (breaking)

0.8.0+20241009.0 Oct 15, 2024
0.7.0+20240821.0 Sep 3, 2024
0.6.0+20240710.0 Jul 15, 2024
0.5.0+20240502.0 May 8, 2024
0.1.0 Aug 28, 2023

#500 in Database interfaces

Download history 9/week @ 2024-08-21 104/week @ 2024-08-28 54/week @ 2024-09-04 20/week @ 2024-09-11 18/week @ 2024-09-18 22/week @ 2024-09-25 37/week @ 2024-10-02 104/week @ 2024-10-09 73/week @ 2024-10-16 5/week @ 2024-10-23 2/week @ 2024-10-30 5/week @ 2024-11-06 17/week @ 2024-11-13 27/week @ 2024-11-20 7/week @ 2024-11-27 155/week @ 2024-12-04

206 downloads per month
Used in oxide-httpmock

MPL-2.0 license

2.5MB
51K SLoC

The Oxide Rust SDK

SDK for the Oxide API.

Installation

The oxide crate is available on crates.io. You'll probably want to use tokio as well. Add them to your Cargo.toml file or use cargo add:

$ cargo add oxide
$ cargo add tokio

Authentication

To connect to the Oxide API, the SDK needs a host URL and a token. There are several ways to specify these:

  • Configuration files: the CLI's oxide auth login command generates config.toml and credentials.toml in $HOME/.config/oxide/. The credentials file contains sensitive information such as tokens and user IDs.
  • Environment variables: You can set the OXIDE_HOST and OXIDE_TOKEN environment variables.
  • Explicit host URL and token.

The simplest way to create an authenticated client is to use oxide::Client::new_authenticated(), which uses the same credentials and authentication logic as the CLI. By default, it reads data from configuration files in $HOME/.config/oxide.

Example

Create a new oxide::Client like this:

use futures::StreamExt;
use oxide::{Client, prelude::*};

#[tokio::main]
async fn main() {
    // Make a client from the on-disk configuration.
    let client = Client::new_authenticated()
        .expect("unable to create an authenticated client");

    // Start using the client!

    // For example we can look at the projects in our silo:
    let mut projects = client.project_list().stream();
    loop {
        match projects.next().await {
            // No more items.
            None => break,
            // Print the name of a project.
            Some(Ok(project)) => println!("project {}", *project.name),
            // Something went wrong
            Some(Err(err)) => println!("error {}", err),
        }
    }
}

Dependencies

~12–27MB
~428K SLoC