river_core/
chat_delegate.rs1use serde::{Deserialize, Serialize};
2
3pub type RoomKey = [u8; 32];
5
6pub type RequestId = u64;
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
11pub enum ChatDelegateRequestMsg {
12 StoreRequest {
14 key: ChatDelegateKey,
15 value: Vec<u8>,
16 },
17 GetRequest {
18 key: ChatDelegateKey,
19 },
20 DeleteRequest {
21 key: ChatDelegateKey,
22 },
23 ListRequest,
24
25 StoreSigningKey {
28 room_key: RoomKey,
29 signing_key_bytes: [u8; 32],
30 },
31 GetPublicKey {
33 room_key: RoomKey,
34 },
35
36 SignMessage {
40 room_key: RoomKey,
41 request_id: RequestId,
42 message_bytes: Vec<u8>,
43 },
44 SignMember {
46 room_key: RoomKey,
47 request_id: RequestId,
48 member_bytes: Vec<u8>,
49 },
50 SignBan {
52 room_key: RoomKey,
53 request_id: RequestId,
54 ban_bytes: Vec<u8>,
55 },
56 SignConfig {
58 room_key: RoomKey,
59 request_id: RequestId,
60 config_bytes: Vec<u8>,
61 },
62 SignMemberInfo {
64 room_key: RoomKey,
65 request_id: RequestId,
66 member_info_bytes: Vec<u8>,
67 },
68 SignSecretVersion {
70 room_key: RoomKey,
71 request_id: RequestId,
72 record_bytes: Vec<u8>,
73 },
74 SignEncryptedSecret {
76 room_key: RoomKey,
77 request_id: RequestId,
78 secret_bytes: Vec<u8>,
79 },
80 SignUpgrade {
82 room_key: RoomKey,
83 request_id: RequestId,
84 upgrade_bytes: Vec<u8>,
85 },
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
89pub struct ChatDelegateKey(pub Vec<u8>);
90
91impl ChatDelegateKey {
92 pub fn new(key: Vec<u8>) -> Self {
93 Self(key)
94 }
95
96 pub fn as_bytes(&self) -> &[u8] {
97 &self.0
98 }
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize)]
103pub enum ChatDelegateResponseMsg {
104 GetResponse {
106 key: ChatDelegateKey,
107 value: Option<Vec<u8>>,
108 },
109 ListResponse {
110 keys: Vec<ChatDelegateKey>,
111 },
112 StoreResponse {
113 key: ChatDelegateKey,
114 value_size: usize,
115 result: Result<(), String>,
116 },
117 DeleteResponse {
118 key: ChatDelegateKey,
119 result: Result<(), String>,
120 },
121
122 StoreSigningKeyResponse {
125 room_key: RoomKey,
126 result: Result<(), String>,
127 },
128 GetPublicKeyResponse {
130 room_key: RoomKey,
131 public_key: Option<[u8; 32]>,
133 },
134
135 SignResponse {
138 room_key: RoomKey,
139 request_id: RequestId,
141 signature: Result<Vec<u8>, String>,
143 },
144}