feat: added a few more packet definitions

This commit is contained in:
antifallobst 2024-05-21 15:05:42 +02:00
parent e6fa8b694c
commit 2e84eca15a
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
1 changed files with 42 additions and 9 deletions

View File

@ -1,6 +1,7 @@
mod error;
pub use error::Error;
use std::collections::HashMap;
use std::fmt::Formatter;
use aes_gcm_siv::{AeadInPlace, Aes256GcmSiv, Nonce};
@ -23,29 +24,61 @@ impl IdPool {
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum FormField {
String,
Password,
Integer,
Date,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
text: Option<String>,
attachments: Option<Vec<(String, Vec<u8>)>>,
}
#[repr(u32)]
#[derive(Debug, Clone, Serialize, Deserialize, Display)]
pub enum Request {
// Misc
Close = 0x000_00000,
Close = 0x000_00000, // Core + CBS
// Handshake
HandshakeUpgradeConnection = 0x001_00000,
HandshakeApiVersion(String) = 0x001_00001,
HandshakeConfig = 0x001_00002,
HandshakeSuccess = 0x001_00003,
HandshakeUpgradeConnection = 0x001_00000, // CBS
HandshakeApiVersion(String) = 0x001_00001, // Core + CBS
HandshakeConfig = 0x001_00002, // Core + CBS
HandshakeSuccess = 0x001_00003, // Core
// Account Setup
AccountSetupSelectOption(Vec<String>) = 0x002_00000, // CBS
AccountSetupGetForm(HashMap<String, (FormField, bool)>) = 0x002_00001, // CBS
AccountSetupSuccess = 0x002_00002, // CBS
AccountSetupFailure(String) = 0x002_00003, // CBS
// Sync
InitialSyncReady = 0x003_00000, // CBS
// Chat
ChatReceivedMessage(String, Message) = 0x004_00000, // CBS
ChatReceivedEvent(String, String) = 0x004_00001, // CBS
}
#[repr(u32)]
#[derive(Debug, Clone, Serialize, Deserialize, Display)]
pub enum Response {
// Account Setup
AccountSetupSelectOption(u64) = 0x002_00000, // Core
AccountSetupFilledForm(HashMap<String, String>) = 0x002_00001, // Core
// Standard success / neutral responses
Success = 0xFFE_00000,
Ackknowledged = 0xFFE_00001,
Success = 0xFFE_00000, // Core + CBS
Ackknowledged = 0xFFE_00001, // Core + CBS
// Standard error responses
RessourceTimeout = 0xFFF_00000,
PermissionDenied = 0xFFF_00001,
UnexpectedRequest = 0xFFF_00000, // Core + CBS
RessourceTimeout = 0xFFF_00001, // Core + CBS
PermissionDenied = 0xFFF_00002, // Core
}
#[derive(Debug, Clone, Serialize, Deserialize)]