Skip to main content

Channel

Struct Channel 

Source
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: TabKind

a real channel, or one of the virtual tabs (see TabKind).

§name: String§platform: Platform

primary 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: bool

the 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: u64

wall-clock ms of the last heat update — decay is computed against it.

§messages: VecDeque<Message>§seq: u64

lines 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

Source

pub fn new(name: &str, platform: Platform, cap: usize) -> Channel

Source

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.

Source

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).

Source

pub fn unread(&self) -> Unread

the tab’s unread state.

Source

pub fn ping(&mut self)

flag the most recent line as a ping (caller knows who “me” is).

Source

pub fn set_pin(&mut self, pin: Option<Pin>)

a pin arrived (Some) or was cleared (None).

Source

pub fn visible_pin(&self) -> Option<&Pin>

the pin to show, unless the user dismissed this very one.

Source

pub fn dismiss_pin(&mut self) -> bool

hide the current pin (a newer one will show again). false = none shown.

Source

pub fn flag_event(&mut self)

flag the tab as holding an unseen stream event.

Source

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.

Source

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.

Source

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).

Source

pub fn mark_seen(&mut self)

the tab is on screen — everything it holds is now seen.

Source

pub fn subs(&self) -> impl Iterator<Item = (Platform, &str)>

every source feeding this tab, primary first.

Source

pub fn matches(&self, platform: Platform, name: &str) -> bool

does a line for (platform, channel) belong to this tab?

Source

pub fn merged(&self) -> bool

is this a merged (multi-source) tab?

Source

pub fn cool(&mut self, now_ms: u64)

advance heat decay to now_ms without adding anything (idle cooling).

Source

pub fn first_sight( &mut self, platform: Platform, channel: &str, id: Option<&str>, ) -> bool

is this the first time this tab sees the platform message id of channel? false = it was already drawn: drop the copy. a line with no id can’t be told apart from a repeat, so it always counts as new.

Source

pub fn backfill(&mut self, channel: &str, msgs: Vec<Message>)

seed scrollback with archived history of channel: prepended oldest-outward, skipping any message id already drawn (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.

Source

pub fn record(&mut self, msg: Message, now_ms: u64)

record a message: decay to now, add one increment, snapshot heat onto the line, then store it (evicting the oldest past the cap).

Trait Implementations§

Source§

impl Clone for Channel

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Channel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.