Expand description
§FaunaDB
faunadb is a client for the Fauna database in Rust. It provides the query
and expression types, (de-)serialization and an asynchronous client.
Additionally the crate holds a SyncClient wrapper for synchronous
execution, enabled with the sync_client feature flag.
Most of the type checks are handled in Fauna and the functions accept anything that can be converted to the Expr enum, allowing the usage of different Fauna types in a more dynamic manner.
§Asynchronous example:
use futures::{future::lazy, Future};
use faunadb::prelude::*;
fn main() {
let client = Client::builder("my_fauna_secret").build().unwrap();
let query = Filter::new(
Lambda::new("x", Gt::new(Var::new("x"), 2)),
Array::from(vec![1, 2, 3]),
);
tokio::run(lazy(move || {
client
.query(query)
.map(|response| {
println!("{:#?}", response);
})
.map_err(|error: faunadb::error::Error| {
println!("Error: {:#?}", error);
})
}));
}§Synchronous example:
use faunadb::prelude::*;
fn main() {
let mut client = Client::builder("my_fauna_secret").build_sync().unwrap();
let query = Filter::new(
Lambda::new("x", Gt::new(Var::new("x"), 2)),
Array::from(vec![1, 2, 3]),
);
match client.query(query) {
Ok(response) => println!("{:#?}", response),
Err(error) => println!("Error: {:#?}", error),
}
}Modules§
- client
- Tools for communicating with Fauna.
- error
- expr
- A Fauna expression that is either a value or a function that evaluates to a value.
- prelude
- query
- A special case of an expression that needs to be evaluated to a value.
Macros§
- boxed_
query - A helper macro to implement
Fromtrait from the given query type into theQueryenum, boxing the query. - int_
expr - A convenience to convert a type of a signed integer into Fauna
Expr. - query
- A helper macro to implement
Fromtrait from the given query type into theQueryenum. - uint_
expr - A convenience to convert a type of a unsigned integer into Fauna
Expr.