Trait zng_wgt_text::TxtParseValue

source ·
pub trait TxtParseValue: VarValue {
    // Required methods
    fn from_txt(txt: &Txt) -> Result<Self, Txt>;
    fn to_txt(&self) -> Txt;
}
Expand description

Represents a type that can be a var value, parse and display.

This trait is used by txt_parse. It is implemented for all types that are VarValue + FromStr + Display where FromStr::Err: Display.

Required Methods§

source

fn from_txt(txt: &Txt) -> Result<Self, Txt>

Try parse Self from txt, formats the error for display.

Note that the widget context is not available here as this method is called in the app context.

source

fn to_txt(&self) -> Txt

Display the value, the returned text can be parsed back to an equal value.

Note that the widget context is not available here as this method is called in the app context.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> TxtParseValue for T
where T: VarValue + FromStr + Display, <Self as FromStr>::Err: Display,