Official Rust client for Central Dogma

Overview

centraldogma-rs

Official Rust Client for Central Dogma.

Full documentation is available at https://docs.rs/centraldogma

Getting started

Installing

Add centraldogma crate and version to Cargo.toml.

centraldogma = "0.1.0"

Async support with tokio

The client uses reqwest to make HTTP calls, which internally uses the tokio runtime for async support. As such, you may require to take a dependency on tokio in order to use the client.

tokio = { version = "1.2.0", features = ["full"] }

Create a client

Create a new client to make API to CentralDogma using the Client struct.

use centraldogma::Client;

#[tokio::main]
fn main() {
    // with token
    let client = Client::new("http://localhost:36462", Some("token")).await.unwrap();
    // without token
    let client = Client::new("http://localhost:36462", None).await.unwrap();
    // your code ...
}

Making typed API calls

Typed API calls are provided behind traits:

Examples

Get File
use centraldogma::{Client, ContentService};

#[tokio::main]
fn main() {
    // without token
    let client = Client::new("http://localhost:36462", None).await.unwrap();

    let file = client
        .repo("project", "repository")
        .get_file(Revision::HEAD, Query::of_text("/a.yml"))
        .await
        .unwrap();
    // your code ...
}
Push
use centraldogma::{Client, ContentService};

#[tokio::main]
fn main() {
    let client = Client::new("http://localhost:36462", None).await.unwrap();
    let changes = vec![Change {
        path: "/a.json".to_string(),
        content: ChangeContent::UpsertJson(serde_json::json!({"a":"b"})),
    }];
    let result = client
        .repo("foo", "bar")
        .push(
            Revision::HEAD,
            CommitMessage::only_summary("Add a.json"),
            changes,
        )
        .await
        .unwrap();
Watch file change
use centraldogma::{Client, WatchService};

#[tokio::main]
fn main() {
    let client = Client::new("http://localhost:36462", None).await.unwrap();
    let stream = client
        .repo("foo", "bar")
        .watch_file_stream(&Query::identity("/a.json").unwrap())
        .unwrap();

    tokio::spawn(async move {
        while let Some(result) = stream.next().await {
            // your code ...
        }
    })

Contributing

See CONTRIBUTING.md.

You might also like...
Telegram bot API client for Rust
Telegram bot API client for Rust

Frankenstein Telegram bot API client for Rust. It's a complete wrapper for Telegram bot API and it's up to date with version 5.2 of the API. Frankenst

Streaming STOMP client for Rust

tokio-stomp An async STOMP client (and maybe eventually, server) for Rust, using the Tokio stack. It aims to be fast and fully-featured with a simple

A minecraft-like multi version client implemented in Rust.
A minecraft-like multi version client implemented in Rust.

Leafish Multi-version Minecraft-compatible client written in Rust, forked from Stevenarella. Chat Chat takes place on Matrix and Discord. The channels

Skytable rust client support library for the bb8 connection pool

bb8-skytable Skytable rust client support library for the bb8 connection pool. Heavily based on bb8-redis Basic usage example use bb8_skytable::{

Rust client for apache iotdb.

Apache IoTDB Apache IoTDB (Database for Internet of Things) is an IoT native database with high performance for data management and analysis, deployab

A firebase HTTP v1 client implementation in Rust using google-authz

firebase-client A firebase HTTP v1 client implementation in Rust using the google_authz library. Example There are two ways to send notifications, one

Rust client for KairosDB

Rust Client for KairosDB   Description A simple rust language client for the time series database KairosDB. Documentation Full documentation for rust-

CouchDB client library for the Rust programming language

CouchDB This project is reborn! As of its v0.6.0 release, the couchdb crate has new life as a toolkit instead of providing a full-blown client. In a n

rinflux is Rust based influx client implementation that have been inspired from influx other language implementation, developed with 💖
rinflux is Rust based influx client implementation that have been inspired from influx other language implementation, developed with 💖

Unofficial InfluxDB Driver for Rust This library is a work in progress. This means a feature you might need is not implemented yet or could be handled

Comments
  • Implement 'From' trait instead of dedicate method 'from'

    Implement 'From' trait instead of dedicate method 'from'

    https://github.com/line/centraldogma-rs/blob/5b8b3e12c58a3631cb0e78a10ed699feab9019ac/src/model.rs#L52-L54

    The method from above could be replaced with impl From<i64> for Revision and then we could use a fancy code like:

    let rev: Revision = -1.into();
    
    opened by jayong93 0
The official MongoDB Rust Driver

MongoDB Rust Driver This repository contains the officially supported MongoDB Rust driver, a client side library that can be used to interact with Mon

mongodb 1.1k Dec 30, 2022
This is superseded by the official MongoDB Rust Driver

This Repository is NOT a supported MongoDB product MongoDB Rust Driver Prototype NOTE: This driver is superseded by the official MongoDB Rust driver,

MongoDB, Inc. Labs 382 Nov 15, 2022
The spatial message broker and database for real-time multiplayer experiences. Official Rust implementation.

WorldQL Server Rust implementation of WorldQL, the spatial message broker and database for real-time multiplayer experiences Setup Instructions ⚠️ Thi

null 214 Jan 2, 2023
Affine-client is a client for AFFINE based on Tauri

Affine Client affine-client is a client for AFFINE based on Tauri Supported Platforms Windows Linux MacOS Download https://github.com/m1911star/affine

Horus 216 Dec 25, 2022
Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async

CDRS CDRS is looking for maintainers CDRS is Apache Cassandra driver written in pure Rust. ?? Looking for an async version? async-std https://github.c

Alex Pikalov 338 Jan 1, 2023
CouchDB client-side library for the Rust programming language

Chill Chill is a client-side CouchDB library for the Rust programming language, available on crates.io. It targets Rust Stable. Chill's three chief de

null 35 Jun 26, 2022
A Rust client for the ElasticSearch REST API

rs-es Introduction An ElasticSearch client for Rust via the REST API. Targetting ElasticSearch 2.0 and higher. Other clients For later versions of Ela

Ben Ashford 218 Dec 27, 2022
An Elasticsearch REST API client for Rust

elastic elastic is an efficient, modular API client for Elasticsearch written in Rust. The API is targeting the Elastic Stack 7.x. elastic provides st

null 249 Oct 18, 2022
An etcd client library for Rust.

etcd An etcd client library for Rust. etcd on crates.io Documentation for the latest crates.io release Running the tests Install Docker and Docker Com

Jimmy Cuadra 138 Dec 27, 2022
Mysql client library implemented in rust.

mysql This crate offers: MySql database driver in pure rust; connection pool. Features: macOS, Windows and Linux support; TLS support via nativetls cr

Anatoly I 548 Dec 31, 2022