Skip to main content

Window

Struct Window 

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

The 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

Source

pub fn empty() -> Self

A window holding nothing.

Source

pub fn messages(&self) -> &[Message]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Default for Window

Source§

fn default() -> Self

Returns the “default value” for a type. 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
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more