1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Durable sink trait and a no-op implementation for tests.
//!
//! Durable events (see [`SessionEvent::is_durable`]) are dispatched
//! synchronously to an implementor of [`DurableSink`]. The sink is
//! expected to buffer or persist the event before returning; the bus
//! guarantees no durable event is silently dropped.
//!
//! [`SessionEvent::is_durable`]: crate::session::SessionEvent::is_durable
use Arc;
use crateSessionEvent;
/// A write-ahead sink for durable [`SessionEvent`]s.
///
/// Implementors are responsible for persisting or queueing the event
/// before returning from [`DurableSink::write`]. Errors must be reported
/// through the returned `Result` so callers can fall back to logging —
/// **never swallow durable-write failures silently**.
///
/// # Thread-safety
///
/// Implementations must be `Send + Sync + 'static` and are shared behind
/// `Arc`. Interior mutability (e.g. `tokio::sync::Mutex`) is the
/// implementor's responsibility.
///
/// # Examples
///
/// A minimal in-memory sink useful in tests:
///
/// ```rust
/// use std::sync::{Arc, Mutex};
/// use codetether_agent::session::{DurableSink, SessionEvent};
///
/// struct Collector(Arc<Mutex<Vec<String>>>);
/// impl DurableSink for Collector {
/// fn write(&self, event: &SessionEvent) -> std::io::Result<()> {
/// self.0.lock().unwrap().push(format!("{event:?}"));
/// Ok(())
/// }
/// }
///
/// let c = Collector(Arc::new(Mutex::new(Vec::new())));
/// c.write(&SessionEvent::Done).unwrap();
/// ```
/// A [`DurableSink`] that drops every event. Useful as a default when the
/// caller has no persistence requirement (e.g. in unit tests or one-shot
/// CLI invocations).
///
/// # Examples
///
/// ```rust
/// use codetether_agent::session::{DurableSink, NoopSink, SessionEvent};
///
/// let sink = NoopSink;
/// sink.write(&SessionEvent::Done).unwrap();
/// ```
;
/// Type alias for the shared sink handle used inside [`crate::session::SessionBus`].
pub type SharedSink = ;