aether_protocol/
request.rs

1// File: src/request.rs
2// =============================================================================
3// This file defines the top-level `Request` enum. This is the single, unified
4// type that represents every possible command a client can send to the server.
5
6use crate::types::{BatchRequest, Filter, QueryOptions, Record};
7use serde::{Deserialize, Serialize};
8
9/// The primary enum representing all possible client requests.
10#[derive(Serialize, Deserialize, Debug, PartialEq)]
11pub enum Request {
12    // --- Database Management ---
13    CreateDatabase { db_name: String },
14    DropDatabase { db_name: String },
15    ListDatabases,
16
17    // --- Collection Management ---
18    ListCollections,
19    CreateCollection { db_name: String, collection_name: String },
20    DropCollection { db_name: String, collection_name: String },
21    GetStats,
22    Flush,
23
24    // --- Index Management ---
25    CreateIndex { db_name: String, collection: String, field_name: String },
26    DropIndex { db_name: String, collection: String, field_name: String },
27    ListIndexes { db_name: String, collection: String },
28
29    // --- Record Operations (CRUD) ---
30    CreateRecord { db_name: String, collection: String, record_id: String, data: Record },
31    UpdateRecord { db_name: String, collection: String, record_id: String, data: Record },
32    UpsertRecord { db_name: String, collection: String, record_id: String, data: Record },
33    GetRecord { db_name: String, collection: String, record_id: String },
34    DeleteRecord { db_name: String, collection: String, record_id: String, cascade: bool },
35    GetLastInsertId,
36
37    // --- Querying & Relational ---
38    FindRecords {
39        db_name: String,
40        collection: String,
41        filter: Filter,
42        options: Option<QueryOptions>,
43    },
44    CountRecords {
45        db_name: String,
46        collection: String,
47        filter: Filter,
48    },
49    GetRecordWithRelated {
50        db_name: String,
51        primary_collection: String,
52        primary_record_id: String,
53        relation_key_field: String,
54        related_collection: String, 
55    },
56    ExecuteBatchGet(BatchRequest),
57}