Skip to main content

Reading

Struct Reading 

Source
pub struct Reading {
    pub used: Option<u64>,
    pub denominator: usize,
    pub marker: Option<f64>,
}
Expand description

One reading of the context bar: what was used, out of what, with the tripwire where the compaction policy puts it.

used is None before the first turn, which is not the same as zero: a bar that is 0% full and a bar that has not been measured look identical, and only one of them is a fact.

Fields§

§used: Option<u64>

Tokens in the last assembled prompt. The server’s own count when it gave one, else the runtime’s estimate from characters.

§denominator: usize

The model’s window where it is known, else the configured rail, else 0 for “nobody stated a number”.

§marker: Option<f64>

Where compaction starts, as a share of the denominator. None when it is off or unknown.

Implementations§

Source§

impl Reading

Source

pub fn new(used: Option<u64>, denominator: usize, marker: Option<f64>) -> Self

Source

pub fn share(&self) -> Option<f64>

The fill as a share of the window. None when there is nothing to be a share of.

Source

pub fn passed(&self) -> bool

Whether the prompt has gone past the tripwire. False when there is no tripwire.

Source

pub fn bar(&self, width: usize) -> String

The bar itself, width cells wide. Never empty: before the first turn it is the empty bar with the tripwire on it, which is what the terminal has always drawn.

Source

pub fn pieces(&self, width: usize) -> Pieces

The read-out’s parts, for a surface that colours them differently: 12.3K/328K, the bar with its tripwire, 4%, and — when nobody stated a denominator — the reason there is no bar instead of a bar against a number the model was never told.

Source

pub fn text(&self, width: usize) -> String

The whole read-out in words: ctx 12.3K/328K ██░░░░░░│░░ 4%, ctx --/328K ░░░░░░░░│░ before the first turn, or a plain token count when nobody stated a denominator.

The three surfaces read this, and the two that draw colour read Self::pieces, so none of them can drift into a second opinion about a percentage.

Trait Implementations§

Source§

impl Clone for Reading

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 Copy for Reading

Source§

impl Debug for Reading

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Reading

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Reading

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> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

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

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

impl<T> WithSubscriber for T

Source§

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

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

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