mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-07-02 22:19:35 +00:00
The client, not the app, now drives the transport; events are delivered asynchronously, per ADR 0001. - ChatClient owns Arc<Mutex<Core>> + a worker thread. - The worker select!s over the inbound and shutdown channels; Drop joins it. Outbound runs on the caller's thread. - A single Transport (DeliveryService + inbound()) owns both directions of the boundary, so the client takes one transport rather than a (delivery, inbound) pair. InProcessDelivery::new, CDelivery, and chat-cli's transports implement it. - FFI replaces client_receive with client_push_inbound + client_poll_events. - chat-cli drains Receiver<Event>; inbound and event channels are both crossbeam. - Corrects ADR 0001's inbound sequence to push — the worker parks on select!, it never polls.
31 lines
823 B
Rust
31 lines
823 B
Rust
//! Application-facing chat events.
|
|
//!
|
|
//! Each variant of [`Event`] describes one observable thing the application
|
|
//! cares about: a new conversation has appeared, a message was decrypted on
|
|
//! an existing one, and so on. The enum is `#[non_exhaustive]` so new
|
|
//! variants can be added without breaking exhaustive matches in dependent
|
|
//! crates.
|
|
|
|
use std::sync::Arc;
|
|
|
|
use libchat::ConversationClass;
|
|
|
|
/// A discrete chat event.
|
|
#[non_exhaustive]
|
|
#[derive(Debug, Clone)]
|
|
pub enum Event {
|
|
/// A new conversation has appeared.
|
|
ConversationStarted {
|
|
convo_id: Arc<str>,
|
|
class: ConversationClass,
|
|
},
|
|
/// User content arrived on an existing conversation.
|
|
MessageReceived {
|
|
convo_id: Arc<str>,
|
|
content: Vec<u8>,
|
|
},
|
|
InboundError {
|
|
message: String,
|
|
},
|
|
}
|