surrealdb/lib.rs
1//! This library provides a low-level database library implementation, a remote
2//! client and a query language definition, for [SurrealDB](https://surrealdb.com), the ultimate cloud database for
3//! tomorrow's applications. SurrealDB is a scalable, distributed,
4//! collaborative, document-graph database for the realtime web.
5//!
6//! This library can be used to start an [embedded](crate::engine::local)
7//! in-memory datastore, an embedded datastore persisted to disk, a
8//! browser-based embedded datastore backed by IndexedDB, or for connecting to a distributed [TiKV](https://tikv.org) key-value store.
9//!
10//! It also enables simple and advanced querying of a
11//! [remote](crate::engine::remote) SurrealDB server from server-side or
12//! client-side code. All connections to SurrealDB are made over WebSockets by
13//! default, and automatically reconnect when the connection is terminated.
14
15#![doc(html_favicon_url = "https://surrealdb.s3.amazonaws.com/favicon.png")]
16#![doc(html_logo_url = "https://surrealdb.s3.amazonaws.com/icon.png")]
17#![cfg_attr(docsrs, feature(doc_cfg))]
18
19#[cfg(all(target_family = "wasm", feature = "ml"))]
20compile_error!("The `ml` feature is not supported on Wasm.");
21
22#[macro_use]
23extern crate tracing;
24
25mod api;
26
27#[doc(hidden)]
28/// Channels for receiving a SurrealQL database export
29pub mod channel {
30 pub use async_channel::{Receiver, Sender, bounded, unbounded};
31}
32
33/// Different error types for embedded and remote databases
34pub mod error {
35 pub use crate::api::err::Error as Api;
36 pub use crate::core::err::Error as Db;
37}
38
39#[cfg(feature = "protocol-http")]
40#[doc(hidden)]
41pub use crate::api::headers;
42#[doc(inline)]
43pub use crate::api::{
44 Connect, Connection, Response, Surreal, engine, method, opt,
45 value::{
46 self, Action, Bytes, Datetime, Notification, Number, Object, RecordId, RecordIdKey, Value,
47 },
48};
49
50/// A specialized `Result` type
51pub type Result<T> = anyhow::Result<T>;
52pub use anyhow::Error;
53// Re-exporting core so it can be imported as `crate::core` so it's not grouped with third
54// party crates.
55use surrealdb_core as core;