π Satori Rust SDK
A comprehensive Rust client library for interacting with the Satori database via WebSockets. Satori is a powerful in-memory database with support for CRUD operations, advanced queries, graph relationships, encryption, AI-powered semantic search, and mindspace conversations.
β¨ Features
- Ultra-fast CRUD operations β‘
- Advanced queries using
field_arrayfor conditional operations π - Real-time notifications π’
- Graph-like relations (vertices and edges) πΈοΈ
- Data encryption and decryption using AES π
- Approximate Nearest Neighbor (ANN) search for semantic similarity π―
- Mindspace conversations for AI-powered context-aware chat π¬
π Installation
Add the following to your Cargo.toml:
[]
= "0.1.8"
= { = "1.36", = ["full"] }
= "1.0"
π Quick Start
use Satori;
async
π Command Reference
All operations are invoked via WebSocket with a JSON request format. The client provides convenient methods for each operation.
Base Request Structure
ποΈ CRUD Operations
SET - Create Data
Creates a new object in the database. If no key is provided, a UUID is automatically generated.
client.set.await?;
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
string | No | Object key. If omitted, a UUID is generated |
data |
JSON | No | Object data content (default: {}) |
type |
string | No | Object class/type (default: "normal") |
expires |
boolean | No | Whether object expires (default: false) |
expiration_time |
integer | No | Expiration timestamp in milliseconds |
GET - Read Data
Retrieves one or more objects from the database. If key is "*", returns all objects in memory.
// Get single object
let user = client.get.await?;
// Get all objects
let all = client.get.await?;
// Query by field
let results = client.get.await?;
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
string | No* | Object key to retrieve. Use "*" for all objects |
field_array |
array | No* | Query conditions for field-based search |
one |
boolean | No | Return only first match (default: false) |
max |
integer | No | Maximum results to return |
encryption_key |
string | No | Key to decrypt encrypted objects |
*Either key or field_array must be provided, but not both.
PUT - Update Data
Updates one or more fields of an existing object.
client.put.await?;
// Batch update using field_array
client.put.await?;
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
string | No* | Object key to update |
field_array |
array | No* | Query to select objects for batch update |
replace_field |
string | Yes | Field name to update |
replace_value |
any | Yes | New value for the field |
encryption_key |
string | No | Key for encrypted objects |
*Either key or field_array must be provided.
DELETE - Remove Data
Removes one or more objects from the database.
client.delete.await?;
// Delete multiple objects matching a query
client.delete.await?;
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
string | No* | Object key to delete |
field_array |
array | No* | Query to select objects for deletion |
*Either key or field_array must be provided.
π¦ Array Manipulation
PUSH - Add to Array
Appends a value to an array field within an object.
client.push.await?;
POP - Remove Last from Array
Removes and returns the last element from an array field.
client.pop.await?;
SPLICE - Remove First from Array
Removes the first element from an array field.
client.splice.await?;
REMOVE - Remove Specific Value
Removes a specific value from an array field by finding and removing the first matching element.
client.remove.await?;
Common Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
string | No* | Object key |
field_array |
array | No* | Query for batch operation |
array |
string | Yes | Name of the array field |
value |
any | Yes* | Value to add/remove |
encryption_key |
string | No | Key for encrypted objects |
*Required for PUSH and REMOVE; not required for POP and SPLICE.
π Encryption
ENCRYPT
Encrypts the data field of an object using AES encryption.
client.encrypt.await?;
DECRYPT
Decrypts an encrypted object's data using the provided encryption key.
client.decrypt.await?;
πΈοΈ Graph Operations
SET_VERTEX
Adds vertices (connections) to an object for graph relationships.
// Simple vertex
client.set_vertex.await?;
// Vertex with relation
client.set_vertex.await?;
// Multiple vertices
client.set_vertex.await?;
GET_VERTEX
Retrieves all vertices from an object.
let vertices = client.get_vertex.await?;
DELETE_VERTEX
Removes a specific vertex from an object.
client.delete_vertex.await?;
DFS - Depth-First Search
Traverses the graph starting from a given node using depth-first search.
let results = client.dfs.await?;
GRAPH_BFS - Breadth-First Search
Returns all nodes reachable from a starting node using breadth-first search.
let results = client.graph_bfs.await?;
GRAPH_DFS - Graph Depth-First Search
Returns all nodes reachable from a starting node using depth-first search.
let results = client.graph_dfs.await?;
GRAPH_SHORTEST_PATH
Finds the shortest path between a start node and end node using Dijkstra's algorithm.
let path = client.graph_shortest_path.await?;
GRAPH_CONNECTED_COMPONENTS
Identifies all connected components in the graph (groups of nodes where each node is reachable from any other node in the group).
let components = client.graph_connected_components.await?;
GRAPH_SCC - Strongly Connected Components
Identifies strongly connected components using Tarjan's algorithm.
let scc = client.graph_scc.await?;
GRAPH_DEGREE_CENTRALITY
Calculates the degree centrality (number of connections) for each node in the graph.
let centrality = client.graph_degree_centrality.await?;
GRAPH_CLOSENESS_CENTRALITY
Calculates closeness centrality for each node, which measures how close a node is to all other nodes.
let centrality = client.graph_closeness_centrality.await?;
GRAPH_CENTROID
Finds the node with the highest closeness centrality (the most central node in the graph).
let centroid = client.graph_centroid.await?;
π€ AI Operations
ANN / GET_SIMILAR
Performs approximate nearest neighbor search to find semantically similar objects using vector embeddings.
// Search by vector
let similar = client.ann.await?;
// Search by existing object's embedding
let similar = client.get_similar.await?;
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
vector |
array | No* | Query vector as array of floats |
key |
string | No* | Use embedding from existing object |
k |
integer | No | Number of neighbors to return (default: 5) |
ef |
integer | No | Search width parameter (default: 25) |
use |
string | No | For key-based search: "data" or "embedding" |
*Either vector or key must be provided.
ASK
Uses AI to answer complex questions about the database. The system automatically gathers relevant context.
let response = client.ask.await?;
Note: This operation requires a valid license.
π¬ Mindspace Operations
Mindspaces provide cognitive contexts for AI-powered conversations and semantic operations.
SET_MINDSPACE / CREATE_MINDSPACE
Creates a new mindspace.
let mindspace_id = client.set_mindspace.await?;
// Or use alias
let mindspace_id = client.create_mindspace.await?;
DELETE_MINDSPACE
Removes a mindspace and all its associated context.
client.delete_mindspace.await?;
CHAT_MINDSPACE
Sends a message to a mindspace and receives an AI-generated response. The mindspace maintains conversation context.
let response = client.chat_mindspace.await?;
LECTURE_MINDSPACE
Imports text corpus into a mindspace for semantic search and context retrieval.
client.lecture_mindspace.await?;
π Analytics Operations
GET_OPERATIONS
Returns a log of recent database operations.
let operations = client.get_operations.await?;
GET_ACCESS_FREQUENCY
Returns the query count (access frequency) for a specific object.
let frequency = client.get_access_frequency.await?;
π Real-time Notifications
Receive automatic updates when an object changes:
client.set_notify.await?;
π Response Format
All successful responses follow this general structure:
Error responses:
π§ Key Concepts
| Concept | Description |
|---|---|
| key | Unique identifier of the object |
| type | Object type (e.g., 'user', 'post') |
| data | The actual content stored in the object |
| field_array | Advanced filters for conditional operations |
| vertices | Graph-like relationships between objects |
| encryption_key | Key used for AES encryption/decryption |
| mindspace | Cognitive context for AI conversations |
π€ Contributing
Questions or suggestions? Feel free to open an issue or contribute!
Made with β€οΈ from the Satori team