Rust

[Memory]: the in-memory adapter.

Rust
use utopia_database::Adapter;
use utopia_database::adapter::memory::Memory;

let adapter = Memory::new();
adapter.set_database("app")?;
adapter.create("app").await?;
assert!(adapter.exists("app", None).await?);

Contents

3 submodules, and what the module defines itself.

use utopia_database::adapter::memory::Memory;
Rust
pub struct Memory

The in-memory adapter. See the module docs.

Also implements Default.

memory::documents

Own page

Documents: reads, creates, updates, deletes, sequences, increments, the permission indexes and the unique-index hash tables.

memory::schema

Own page

Databases, collections, attributes, relationship fields and indexes.

memory::store

Own page
use utopia_database::adapter::memory::store::array_merge;
Rust
pub fn array_merge(arrays: &[&Array]) -> Array

String keys of $b overwrite in place, integer keys are renumbered after $a's.

use utopia_database::adapter::memory::store::empty;
Rust
pub fn empty(v: Option<&Value>) -> bool

Undocumented.

use utopia_database::adapter::memory::store::for_each_mut;
Rust
pub fn for_each_mut(a: &mut Array, mut f: impl FnMut(ArrayKey, &mut Value))

Undocumented.

use utopia_database::adapter::memory::store::get;
Rust
pub fn get<'a>(a: &'a Array, path: &[ArrayKey]) -> Option<&'a Value>

$a[k1][k2]... (None when a step is missing or not an array).

use utopia_database::adapter::memory::store::get_array;
Rust
pub fn get_array<'a>(a: &'a Array, path: &[ArrayKey]) -> Option<&'a Array>

$a[k1][k2]... as an array (None when missing or not an array).

use utopia_database::adapter::memory::store::isset;
Rust
pub fn isset(a: &Array, path: &[ArrayKey]) -> bool

Undocumented.

use utopia_database::adapter::memory::store::k;
Rust
pub fn k(s: &str) -> ArrayKey

An array key from text ($a['key']).

use utopia_database::adapter::memory::store::key_of;
Rust
pub fn key_of(v: &Value) -> ArrayKey

The key a value becomes as an array key ($a[$value]): integers stay, strings are normalized, null is "", booleans and floats integers.

use utopia_database::adapter::memory::store::key_value;
Rust
pub fn key_value(key: KeyRef<'_>) -> Value

A key as the value foreach ($a as $key => ...) gives.

use utopia_database::adapter::memory::store::push;
Rust
pub fn push(a: &mut Array, path: &[ArrayKey], value: Value) -> i64

$a[k1][k2]...[] = $value: the key it got.

use utopia_database::adapter::memory::store::s;
Rust
pub fn s(text: &str) -> Value

A string value.

use utopia_database::adapter::memory::store::set;
Rust
pub fn set(a: &mut Array, path: &[ArrayKey], value: Value)

$a[k1][k2]... = $value.

use utopia_database::adapter::memory::store::unset;
Rust
pub fn unset(a: &mut Array, path: &[ArrayKey])

Nothing is created on the way.

use utopia_database::adapter::memory::store::vivify;
Rust
pub fn vivify<'a>(a: &'a mut Array, path: &[ArrayKey]) -> &'a mut Array

Undocumented.