2025-12-22 09:40:46 -08:00
|
|
|
use std::fmt::Debug;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
pub use crate::errors::ChatError;
|
2026-02-06 23:41:12 +07:00
|
|
|
use crate::types::{AddressedEncryptedPayload, ContentData};
|
2025-12-22 09:40:46 -08:00
|
|
|
|
|
|
|
|
pub type ConversationId<'a> = &'a str;
|
|
|
|
|
pub type ConversationIdOwned = Arc<str>;
|
|
|
|
|
|
2026-01-22 06:39:09 +07:00
|
|
|
pub trait Id: Debug {
|
2026-02-10 18:34:33 +01:00
|
|
|
fn id(&self) -> ConversationId<'_>;
|
2025-12-22 09:40:46 -08:00
|
|
|
}
|
|
|
|
|
|
2026-01-22 06:39:09 +07:00
|
|
|
pub trait Convo: Id + Debug {
|
2026-01-29 23:36:18 +07:00
|
|
|
fn send_message(&mut self, content: &[u8])
|
|
|
|
|
-> Result<Vec<AddressedEncryptedPayload>, ChatError>;
|
|
|
|
|
|
2026-02-06 23:41:12 +07:00
|
|
|
/// Decrypts and processes an incoming encrypted frame.
|
|
|
|
|
///
|
|
|
|
|
/// Returns `Ok(Some(ContentData))` if the frame contains user content,
|
|
|
|
|
/// `Ok(None)` for protocol frames (e.g., placeholders), or an error if
|
|
|
|
|
/// decryption or frame parsing fails.
|
|
|
|
|
fn handle_frame(
|
|
|
|
|
&mut self,
|
|
|
|
|
enc_payload: EncryptedPayload,
|
|
|
|
|
) -> Result<Option<ContentData>, ChatError>;
|
|
|
|
|
|
2026-01-29 23:36:18 +07:00
|
|
|
fn remote_id(&self) -> String;
|
2026-03-13 10:15:06 +08:00
|
|
|
|
|
|
|
|
/// Returns the conversation type identifier for storage.
|
2026-03-30 12:59:48 +08:00
|
|
|
fn convo_type(&self) -> ConversationKind;
|
2026-01-22 06:39:09 +07:00
|
|
|
}
|
2025-12-22 09:40:46 -08:00
|
|
|
|
|
|
|
|
mod privatev1;
|
|
|
|
|
|
2026-02-06 23:41:12 +07:00
|
|
|
use chat_proto::logoschat::encryption::EncryptedPayload;
|
2025-12-22 09:40:46 -08:00
|
|
|
pub use privatev1::PrivateV1Convo;
|
2026-03-30 12:59:48 +08:00
|
|
|
use storage::ConversationKind;
|