pub struct Window {
messages: Vec<Message>,
sizes: Vec<usize>,
bytes: usize,
newest_open: Option<usize>,
}Expand description
One conversation’s newest window, and what each frame in it weighs.
The weights are taken once, where a frame enters. A copy’s byte ceiling
is only a ceiling if it is known per frame: measuring the window at each
drop would serialize what the drop is about to throw away, and measuring
the history at each read is the transcript’s own cost. So a frame is
measured as it is pushed, CONVERSATION_CAP_BYTES past which the drop
runs before the push, and what a seed keeps is what its cut measured on the
way in.
Fields§
§messages: Vec<Message>§sizes: Vec<usize>How each message weighs on the wire, one entry per message.
bytes: usizeThe running total of sizes, so a push never walks the window.
newest_open: Option<usize>Where the newest turn’s opening frame sits in messages, None when
the window holds no opening frame for it - either a cut dropped it or
the scan named none.
It is how a drop tells the newest turn’s counters from older ones: a cut at a turn’s first frame takes settled turns, whose counters no page owes, while a cut inside the newest turn owes every counter after its opening. No opening frame means the whole window is one turn, so every dropped counter from its front belongs to that turn.
Implementations§
Source§impl Window
impl Window
pub fn messages(&self) -> &[Message]
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn push(&mut self, message: Message, opened: bool) -> Shed
pub fn push(&mut self, message: Message, opened: bool) -> Shed
One frame the session emitted, and what the ceilings shed for it.
Before the push, so the drop pays for the room it makes. After it,
this one frame is what tips the store into a doubling the drop is about
to throw away. opened says the frame starts a turn, which is what
tells the cut where the newest turn begins.
Sourcepub fn append(&mut self, other: &mut Window)
pub fn append(&mut self, other: &mut Window)
Take everything other holds onto this window’s end.
Not re-cut. What a fold took out plus what arrived while it ran, so until the next push sheds them a merged window may sit past a ceiling’s slack by whatever the fold’s run carried - the split the fold has always had, and the push that follows it is what brings the ceilings back.
Sourcepub fn carry_thinking(&mut self, shed: Shed)
pub fn carry_thinking(&mut self, shed: Shed)
Fold a cut’s thinking debt into the first counter the newest turn still carries.
A handover has no page to fold into. A resume hands the window to the update stream, so the debt rides the frames rather than a serve: the first counter the newest turn carries absorbs it, and every reader of the handover sums the whole turn.
Sourcepub fn tail_of(history: &[Message]) -> (Window, Shed)
pub fn tail_of(history: &[Message]) -> (Window, Shed)
The newest window of history, as a copy to keep or hand over, and what
the cut shed.
Taken from the slice rather than cloned whole and cut, which is the difference between a window-sized allocation and a transcript-sized one: what a connect hands over is the whole conversation, and the copy that keeps it wants the tail. And nothing older than the ceilings is ever weighed: the walk starts at the newest frame and stops once either ceiling’s slack is spent, so a 2.8 GB read pays a window’s worth of measuring rather than a transcript’s.
The openings are the exception to the measure’s stop: a scan from the history’s own start is the only exact answer, and it weighs nothing.
Sourcefn push_with(&mut self, message: Message, opened: bool, budget: Budget) -> Shed
fn push_with(&mut self, message: Message, opened: bool, budget: Budget) -> Shed
A frame on the end, weighed once, dropping first when a ceiling is already passed - the whole cut, drivable at a smaller ceiling.
Sourcefn drop_with(&mut self, budget: Budget) -> Shed
fn drop_with(&mut self, budget: Budget) -> Shed
Drop the oldest messages until the window is back inside the ceilings, and report what went.
A fresh allocation rather than a drain, because a Vec keeps the
store it grew to: the point of the cap is that a copy stops holding the
backing store of a conversation it no longer has, and a drain would
leave it holding all of it with a window’s worth of messages in front.
Sourcefn tail_of_with(history: &[Message], budget: Budget) -> (Window, Shed)
fn tail_of_with(history: &[Message], budget: Budget) -> (Window, Shed)
Self::tail_of’s body, at a ceiling a caller names.
sizes covers history[measured_from..]: what the walk weighed, which
is the newest frames up to whichever ceiling stopped it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Window
impl RefUnwindSafe for Window
impl Send for Window
impl Sync for Window
impl Unpin for Window
impl UnsafeUnpin for Window
impl UnwindSafe for Window
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more