Skip to main content

Row

Struct Row 

Source
pub struct Row {
    buf: String,
    width: usize,
    max: usize,
}
Expand description

One line of the frame, built left to right with its visible width tracked separately from its bytes.

Styling is inline ANSI, so buf.len() says nothing about how wide the line renders; every truncation and every pad has to go through width. That is the entire reason this type exists rather than a String.

Fields§

§buf: String§width: usize§max: usize

Implementations§

Source§

impl Row

Source

pub fn new(max: usize) -> Row

Source

pub fn left(&self) -> usize

Source

pub fn cap(&mut self, max: usize) -> &mut Row

Move the right edge, so a right-aligned field can reserve its space before the left-hand side is written and be clipped away by it.

Source

pub fn put(&mut self, style: &str, s: &str) -> &mut Row

Append text, truncated to what is left of the line.

ponytail: one column per char. A CJK log body renders one cell wide per character here and will run past the right edge; the fix is a unicode-width table, which is a crate, and the payload this reads is attribute keys and metric names. Revisit if a user shows up with a wide-character body.

Source

pub fn plain(&mut self, s: &str) -> &mut Row

Source

pub fn raw(&mut self, s: &str, width: usize) -> &mut Row

Append an already-rendered line of known visible width, byte for byte.

put would rewrite its ESC bytes to · and count each one as a column, which is right for a log body and wrong for a line that came out of another Row. Nothing here can recover the width from the bytes, so the caller states it — pass a line finished with done, which pads to exactly the width it was built for.

Source

pub fn pad_to(&mut self, col: usize) -> &mut Row

Pad with spaces until the cursor sits at col. Never truncates: a column that overflowed its slot pushes the next one right rather than losing it.

Source

pub fn repeat(&mut self, style: &str, c: char, n: usize) -> &mut Row

Repeat c n times, clipped to the line.

Source

pub fn fill(self, style: &str) -> String

Finish the line, padded to full width so a selected row’s reverse-video background reaches the right edge.

Source

pub fn done(self) -> String

Auto Trait Implementations§

§

impl Freeze for Row

§

impl RefUnwindSafe for Row

§

impl Send for Row

§

impl Sync for Row

§

impl Unpin for Row

§

impl UnsafeUnpin for Row

§

impl UnwindSafe for Row

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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
§

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,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

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

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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