coder

Crates.iocoder
lib.rscoder
version0.3.6
sourcesrc
created_at2020-08-03 19:05:40.759622
updated_at2020-08-19 04:47:43.349516
descriptionAsynchronous, pure Rust bindings to the Coder On-Prem API
homepagehttps://coder.com
repositoryhttps://github.com/coadler/coder.rs
max_upload_size
id272620
size460,250
Colin Adler (coadler)

documentation

https://docs.rs/coder

README

Crates.io Docs.rs MIT licensed

coder.rs

An asynchronous, pure Rust wrapper around the Coder Enterprise API.

This is currently experimental. Not all routes have been implemented and the API is expected to change.

Installation

Coder.rs has been tested to work on Rust 1.40+

Add this to your Cargo.toml's [dependencies] section:

coder = { version = "0.3", features = ["rustls"] }

Usage

Coder provides the coder::Coder struct for creating requests.

use std::env;
use std::error::Error;

use coder::{Coder, Executor};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let url = env::var("MANAGER_URL")?;
    let api_key = env::var("API_KEY")?;
    let c = Coder::new(url, api_key)?;

    let res = c.users().me().execute().await?;
    dbg!(res);

    Ok(())
}

// [src/bin/main.rs:19] res = ApiResponse {
//     headers: Headers(
//         {
//             "server": "openresty/1.15.8.2",
//             "date": "Wed, 05 Aug 2020 05:05:11 GMT",
//             "content-type": "application/json",
//             "content-length": "653",
//             "vary": "Accept-Encoding",
//             "vary": "Origin",
//             "strict-transport-security": "max-age=15724800; includeSubDomains",
//             "coder-version": "1.9.0-rc1-220-gd2a04f83a",
//             "x-envoy-upstream-service-time": "20",
//         },
//     ),
//     status_code: 200,
//     response: Ok(
//         User {
//             id: "5e876cf4-10abe9b2e54eb609c5ec1870",
//             name: "Colin Adler",
//             username: "colin",
//             email: "colin@coder.com",
//             dotfiles_git_uri: "",
//             roles: [
//                 "site-manager",
//                 "site-auditor",
//             ],
//             avatar_hash: "28707dc83fdcba2cacaa3ad5e381b34b7cb37b74",
//             key_regenerated_at: 2020-04-03T17:05:56.964782Z,
//             created_at: 2020-04-03T17:05:56.964782Z,
//             updated_at: 2020-05-29T18:10:33.532351Z,
//         },
//     ),
// }

Features

  • rustls - Uses the rustls pure Rust TLS implementation. (default)
  • rust-native-tls - Uses native-tls for TLS which links against the OS default.
Commit count: 0

cargo fmt