pub struct TString {
pub csi: String,
pub raw: String,
}Expand description
a simple representation of a colored and styled string.
Note that this works because of a few properties of cargo’s output:
- styles and colors are always reset on changes
- they’re always in the same order (bold then fg color)
A more generic parsing would have to:
- parse the csi params (it’s simple enough to map but takes code)
- use a simple state machine to keep style (bold, italic, etc.), foreground color, and background color across tstrings
Fields§
§csi: String§raw: StringImplementations§
Source§impl TString
impl TString
pub fn new<S1: Into<String>, S2: Into<String>>(csi: S1, raw: S2) -> Self
pub fn num_badge(num: usize, cat: &str, fg: u8, bg: u8) -> Self
pub fn push_csi(&mut self, params: &Params, action: char)
pub fn draw(&self, w: &mut W) -> Result<()>
Sourcepub fn draw_in(&self, w: &mut W, cols_max: usize) -> Result<usize>
pub fn draw_in(&self, w: &mut W, cols_max: usize) -> Result<usize>
draw the string but without taking more than cols_max cols.
Return the number of cols written
pub fn starts_with(&self, csi: &str, raw: &str) -> bool
pub fn split_off(&mut self, at: usize) -> Self
pub fn is_blank(&self) -> bool
pub fn is_styled(&self) -> bool
pub fn is_unstyled(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TString
impl<'de> Deserialize<'de> for TString
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for TString
impl StructuralPartialEq for TString
Auto Trait Implementations§
impl Freeze for TString
impl RefUnwindSafe for TString
impl Send for TString
impl Sync for TString
impl Unpin for TString
impl UnwindSafe for TString
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IQ for Twhere
T: Serialize,
impl<T> IQ for Twhere
T: Serialize,
Source§fn extract_primitive<P>(&self, path: P) -> Option<String>where
P: IqPath,
fn extract_primitive<P>(&self, path: P) -> Option<String>where
P: IqPath,
Extract a “primitive” value (including strings, simple enum variants, etc)
as a string using the Display implementation of the deep value.
Source§fn extract_json_pretty<P>(&self, path: P) -> Option<String>where
P: IqPath,
fn extract_json_pretty<P>(&self, path: P) -> Option<String>where
P: IqPath,
Extract a value as JSON, pretty
Source§fn extract_value<P, V>(&self, path: P) -> Result<Option<V>, IqError>where
P: IqPath,
V: DeserializeOwned,
fn extract_value<P, V>(&self, path: P) -> Result<Option<V>, IqError>where
P: IqPath,
V: DeserializeOwned,
Extract a value in a type which must implement
Deserialize, from a value, at
the given path. Read more