river_core/
chat_delegate.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
5pub enum ChatDelegateRequestMsg {
6 StoreRequest {
7 key: ChatDelegateKey,
8 value: Vec<u8>,
9 },
10 GetRequest {
11 key: ChatDelegateKey,
12 },
13 DeleteRequest {
14 key: ChatDelegateKey,
15 },
16 ListRequest,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
20pub struct ChatDelegateKey(pub Vec<u8>);
21
22impl ChatDelegateKey {
23 pub fn new(key: Vec<u8>) -> Self {
24 Self(key)
25 }
26
27 pub fn as_bytes(&self) -> &[u8] {
28 &self.0
29 }
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34pub enum ChatDelegateResponseMsg {
35 GetResponse {
36 key: ChatDelegateKey,
37 value: Option<Vec<u8>>,
38 },
39 ListResponse {
40 keys: Vec<ChatDelegateKey>,
41 },
42 StoreResponse {
43 key: ChatDelegateKey,
44 value_size: usize,
45 result: Result<(), String>,
46 },
47 DeleteResponse {
48 key: ChatDelegateKey,
49 result: Result<(), String>,
50 },
51}