From 2e84eca15abce541f03fcfdaeaf9cbd436c83351 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Tue, 21 May 2024 15:05:42 +0200 Subject: [PATCH] feat: added a few more packet definitions --- src/lib.rs | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c1c1f69..2cf7f48 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, + attachments: Option)>>, +} + #[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) = 0x002_00000, // CBS + AccountSetupGetForm(HashMap) = 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) = 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)]