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: usizeImplementations§
Source§impl Row
impl Row
pub fn new(max: usize) -> Row
pub fn left(&self) -> usize
Sourcepub fn cap(&mut self, max: usize) -> &mut Row
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.
Sourcepub fn put(&mut self, style: &str, s: &str) -> &mut Row
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.
pub fn plain(&mut self, s: &str) -> &mut Row
Sourcepub fn raw(&mut self, s: &str, width: usize) -> &mut Row
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.
Sourcepub fn pad_to(&mut self, col: usize) -> &mut Row
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.
Sourcepub fn repeat(&mut self, style: &str, c: char, n: usize) -> &mut Row
pub fn repeat(&mut self, style: &str, c: char, n: usize) -> &mut Row
Repeat c n times, clipped to the line.
Sourcepub fn fill(self, style: &str) -> String
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.
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
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].