ic-dbms-client

Crates.ioic-dbms-client
lib.rsic-dbms-client
version0.3.0
created_at2025-12-11 19:36:55.098203+00
updated_at2025-12-24 16:48:54.937173+00
descriptionic-dbms-canister client library for interacting with the ic-dbms-canister.
homepage
repositoryhttps://github.com/veeso/ic-dbms
max_upload_size
id1980422
size107,563
Christian Visintin (veeso)

documentation

https://docs.rs/ic-dbms-client/

README

ic-dbms-client

logo

license-mit repo-stars downloads latest-version ko-fi conventional-commits

ci coveralls docs

This crate exposes all the types which may be used by an external canister to interact with an IC DBMS Canister instance.

Client

All the client methods can be accessed through the Client trait.

The crate provides an implementation of the client for IC DBMS Canister, called IcDbmsCanisterClient, which can be used on ic canisters.

If you want to use the client in integration tests with pocket-ic, you can use the IcDbmsPocketIcClient implementation, but first you need to enable the pocket-ic feature.

Usage

Add the dependencies

[dependencies]
candid = "0.10"
ic-dbms-api = "0.1"
ic-dbms-client = "0.1"
serde = "1"

Implement the record types

You can define your table as you did for the database, or use a common crate to share the types between the canisters.

use candid::{CandidType, Principal};
use ic_dbms_api::prelude::{Nullable, Query, Table, TableSchema, Text, Uint32, Uint64};
use ic_dbms_client::prelude::{Client as _, IcDbmsCanisterClient};
use serde::Deserialize;

#[derive(Table, CandidType, Clone, Deserialize)]
#[table = "users"]
pub struct User {
    #[primary_key]
    id: Uint64,
    name: Text,
    email: Text,
    age: Nullable<Uint32>,
}

Use the client

let principal = Principal::from_text("...")?;
let client = IcDbmsCanisterClient::new(principal);

let alice = UserInsertRequest {
    id: 1.into(),
    name: "Alice".into(),
    email: "alice@example.com".into(),
    age: Nullable::Value(30.into()),
};

client
    .insert::<User>(User::table_name(), alice, None)
    .await?;

Available Clients

  • IcDbmsCanisterClient: Client implementation for IC canisters.
  • IcDbmsPocketIcClient: Client implementation for pocket-ic integration tests.

Available Methods

All the client methods are defined in the Client trait.

  • acl_add_principal
  • acl_remove_principal
  • acl_allowed_principals
  • begin_transaction
  • commit
  • rollback
  • select
  • insert
  • update
  • delete

Available Types

You can import all the useful types and traits by using the prelude module:

use ic_dbms_client::prelude::*;

Query

Table

Types

Value

License

This project is licensed under the MIT License. See the LICENSE file for details.

Commit count: 0

cargo fmt