Crate rincon_client [−] [src]
Type safe interaction with the ArangoDB REST API.
This module defines types and functions to interact with the REST API of the ArangoDB server. Lets define the concept and terms used throughout the Rincon ArangoDB driver crates.
Each operation on the REST API is represented by a struct in this client lib. These structs are called methods within the Rincon ArangoDB driver. A method is instantiated with the desired parameters and data to get a method call. The method call is executed against an ArangoDB server on a connection that is provided by a connector.
Here is some example code to showcase the basic usage of the client API:
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] struct Person { name: String, age: u16, } // create an instance of our custom struct let person = Person { name: "herbert".to_string(), age: 42 }; // create a new document for with our custom struct as content let new_document = NewDocument::from_content(person); // create a method call for inserting the new document let insert_document = InsertDocument::new("people", new_document); // create a second method call for creating a new collection let create_collection = CreateCollection::with_name("people"); // now execute all the method calls let db_connection = connector.connection("friendsbook"); let people = core.run(db_connection.execute(create_collection))?; let doc_header = core.run(db_connection.execute(insert_document))?; // lets fetch the whole document from the db let (doc_id, _, _) = doc_header.deconstruct(); let get_document = GetDocument::with_id(doc_id); let document: Document<Person> = core.run(db_connection.execute(get_document))?;
This example code uses two variables connector
and core
where you may
wonder what they are. To learn how to instantiate the connector
and the
core
variable see the documentation of the rincon_connector
crate.
The execute()
function of a connection returns a Future
. Thanks to the
power of Future
we can also chain the executions of the method calls by
composing the Future
s like so:
let db_conn = connector.connection("friendsbook"); // chaining the method calls let document: Document<Person> = core.run( db_conn.execute(CreateCollection::with_name("people")) .and_then(|_people| db_conn.execute(InsertDocument::new("people", new_document)) ) .and_then(|doc_header| { let (doc_id, _, _) = doc_header.deconstruct(); db_conn.execute(GetDocument::with_id(doc_id)) }) )?;
Advanced attributes and optional crate features
Some attributes of methods or their results are only meaningful in a certain server configuration, like using RocksDB instead of MMFiles or the server is setup in a cluster. Those attributes are only available in the API of this crate if the crate is compiled with the related feature enabled. The optional crate features are:
mmfiles
: enables MMFiles storage engine related attributes,rocksdb
: enables RocksDB storage engine related attributes,cluster
: enables cluster configuration related attributes,enterprise
: enables attributes supported only by the enterprise version of ArangoDB,
It is not necessary to activate any of the optional crate features if an application does not need to access the feature related attributes.
Modules
admin |
Methods and types for server administration. |
aql |
Methods and types related to AQL queries. |
auth |
Methods and types for user authentication. |
client |
Re-export of all public types of the client API. |
collection |
Methods and types for managing collections. |
cursor |
Methods and types for executing AQL queries. |
database |
Methods and types for managing databases. |
document |
Methods and types for managing documents. |
graph |
Methods and types for managing graphs. |
index |
Methods and types for managing indexes. |
user |
Methods and types for user administration. |