ArikeDB Rust Library
Welcome to the ArikeDB Rust library! This library provides an interface to interact with the Arike Database, an advanced real-time database solution. This documentation will guide you through the process of setting up and using the library effectively.
Getting Started
Installation
To use the ArikeDB Rust library, add it to your Cargo.toml:
[]
= "*"
Connecting to ArikeDB
To connect to an ArikeDB server instance, bring ArikedbClient into scope and instantiate it by calling the connect function.
Basic Connection
use ArikedbClient;
use ;
async
Connection with Authentication
If the server requires authentication, you need to authenticate after connecting.
use ArikedbClient;
use ;
async
Creating Collections
ArikeDB organizes data into collections. Each collection has a name and a set of variables. To create multiple collections in a single call:
client.create_collections.await.unwrap;
Deleting Collections
client.delete_collections.await.unwrap;
Listing Collections
let collections = client.list_collections.await.unwrap;
for collection in collections
Output:
Collection { name: "collection1" }
Collection { name: "collection2" }
Creating Variables
let variables = vec!;
client.create_variables.await.unwrap;
Deleting Variables
client.delete_variables.await.unwrap;
Listing Variables
let variables = client.list_variables.await.unwrap;
for variable in variables
Output:
Variable { name: "var1", vtype: I32, buffer_size: 10 }
Variable { name: "var2", vtype: I32, buffer_size: 5 }
Setting Variables Values
client.set_variables.await.unwrap;
Getting Variables Values
let derived_order = 0;
let data = client.get_variables.await.unwrap;
for point in data
Output:
DataPoint { name: "var1", vtype: I32, timestamp: "1720927547279880000", epoch: Nanosecond, value: "-235" }
DataPoint { name: "var2", vtype: I32, timestamp: "1720927547279880000", epoch: Nanosecond, value: "48" }
Subscribe to Variables Events
Events are generated over variables when they ar set and event condition happens.
spawn;
for i in 0..10
Output:
DataPoint { name: "var1", vtype: I32, timestamp: "1720927881619292000", epoch: Nanosecond, value: "50" }
DataPoint { name: "var2", vtype: I32, timestamp: "1720927881619292000", epoch: Nanosecond, value: "60" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927882629171000", epoch: Nanosecond, value: "51" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927883638571000", epoch: Nanosecond, value: "52" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927884652619000", epoch: Nanosecond, value: "53" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927885664589000", epoch: Nanosecond, value: "54" }
DataPoint { name: "var2", vtype: I32, timestamp: "1720927885664589000", epoch: Nanosecond, value: "56" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927886673866000", epoch: Nanosecond, value: "55" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927887693254000", epoch: Nanosecond, value: "56" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927888703026000", epoch: Nanosecond, value: "57" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927889717038000", epoch: Nanosecond, value: "58" }
DataPoint { name: "var1", vtype: I32, timestamp: "1720927890728150000", epoch: Nanosecond, value: "59" }