pub struct Channel {
pub kind: TabKind,
pub name: String,
pub platform: Platform,
pub extra: Vec<(Platform, String)>,
pub temp: bool,
pub heat: f64,
pub last_ms: u64,
pub messages: VecDeque<Message>,
pub seq: u64,
/* private fields */
}Expand description
live state for a single channel. bounded ring buffer — a raid can flood
forever and we never grow past cap (mele is 8GB; resource-conscious).
heat is a decaying counter driven by message arrivals.
Fields§
§kind: TabKinda real channel, or one of the virtual tabs (see TabKind).
name: String§platform: Platformprimary source — sends target it, and it leads the tab label.
extra: Vec<(Platform, String)>further sources merged into this tab (a +-joined channel). their
lines interleave into the one ring in arrival order.
temp: boolthe unsaved “stream i’m looking at” tab: one slot, never persisted or shared, promoted to a saved tab by keeping it.
heat: f64§last_ms: u64wall-clock ms of the last heat update — decay is computed against it.
messages: VecDeque<Message>§seq: u64lines ever appended at the live end — a monotonic clock for “how many arrived since”, unaffected by the ring evicting old ones.
Implementations§
Source§impl Channel
impl Channel
pub fn new(name: &str, platform: Platform, cap: usize) -> Channel
Sourcepub fn special(kind: TabKind, cap: usize) -> Channel
pub fn special(kind: TabKind, cap: usize) -> Channel
a virtual tab. it joins nothing: subs() is empty, so no line ever
matches it and no part / emote / history call is made for it.
Sourcepub fn deliver(&mut self, msg: Message)
pub fn deliver(&mut self, msg: Message)
append a line to a virtual tab: counts as unread, but keeps the row’s own heat (a feed row’s heat is the server’s, not ours).
Sourcepub fn visible_pin(&self) -> Option<&Pin>
pub fn visible_pin(&self) -> Option<&Pin>
the pin to show, unless the user dismissed this very one.
Sourcepub fn dismiss_pin(&mut self) -> bool
pub fn dismiss_pin(&mut self) -> bool
hide the current pin (a newer one will show again). false = none shown.
Sourcepub fn flag_event(&mut self)
pub fn flag_event(&mut self)
flag the tab as holding an unseen stream event.
Sourcepub fn system(&mut self, msg: Message)
pub fn system(&mut self, msg: Message)
add a client-side line (a send rejection, a connection notice): keeps the cap, but touches neither heat nor unread — it is not chat.
Sourcepub fn insert_by_ts(&mut self, msg: Message) -> bool
pub fn insert_by_ts(&mut self, msg: Message) -> bool
slot a line in by its own time (extra.ts, seconds) — a replayed or
back-dated event, not news: no heat, no unread, no ping. it lands after
the last line that is not newer than it. false = it would sit older than
everything in a full ring, so it is dropped.
Sourcepub fn apply(&mut self, d: &Delete) -> usize
pub fn apply(&mut self, d: &Delete) -> usize
a mod removed lines: mark every matching chat line (events are never
struck). returns how many were marked. the caller has already routed
d to this tab; platform is checked per line (merged tabs).
Sourcepub fn subs(&self) -> impl Iterator<Item = (Platform, &str)>
pub fn subs(&self) -> impl Iterator<Item = (Platform, &str)>
every source feeding this tab, primary first.
Sourcepub fn matches(&self, platform: Platform, name: &str) -> bool
pub fn matches(&self, platform: Platform, name: &str) -> bool
does a line for (platform, channel) belong to this tab?
Sourcepub fn cool(&mut self, now_ms: u64)
pub fn cool(&mut self, now_ms: u64)
advance heat decay to now_ms without adding anything (idle cooling).
Sourcepub fn backfill(&mut self, msgs: Vec<Message>)
pub fn backfill(&mut self, msgs: Vec<Message>)
seed scrollback with archived history: prepended oldest-outward, deduped
against lines already buffered (the live feed may overlap the archive’s
tail), heat untouched — history is cold by definition. msgs is
chronological (oldest first); the cap still bounds the buffer.