[][src]Trait justconfig::processors::Trim

pub trait Trim where
    Self: Sized
{ pub fn trim(self) -> Result<StringItem, ConfigError>;
pub fn trim_start(self) -> Result<StringItem, ConfigError>;
pub fn trim_end(self) -> Result<StringItem, ConfigError>; }

Trims leading, trailing or leading and trailing whitespaces from all config values.

Required methods

Loading content...

Implementations on Foreign Types

impl Trim for Result<StringItem, ConfigError>[src]

pub fn trim(self) -> Result<StringItem, ConfigError>[src]

Trims leading and trailing whitespaces from all config values.

This methods calls String::trim() for all config values of the current configuration item.

Example

defaults.set(conf.root().push_all(&["myitem"]), "   abc\t", "source info");
conf.add_source(defaults);

let value: String = conf.get(ConfPath::from(&["myitem"])).trim().value().unwrap();

assert_eq!(value, "abc");

pub fn trim_start(self) -> Result<StringItem, ConfigError>[src]

Trims leading whitespaces from all configuration value.

This methods calls String::trim_start() for all config values of the current configuration item.

Example

defaults.set(conf.root().push_all(&["myitem"]), "   abc   ", "source info");
conf.add_source(defaults);

let value: String = conf.get(ConfPath::from(&["myitem"])).trim_start().value().unwrap();

// Note that the trailing whitespaces where kept.
assert_eq!(value, "abc   ");

pub fn trim_end(self) -> Result<StringItem, ConfigError>[src]

Trims trailing whitespaces from all configuration value.

This methods calls String::trim_end() for all config values of the current configuration item.

Example

defaults.set(conf.root().push_all(&["myitem"]), "   abc   ", "source info");
conf.add_source(defaults);

let value: String = conf.get(ConfPath::from(&["myitem"])).trim_end().value().unwrap();

// Note that the leading whitespaces where kept.
assert_eq!(value, "   abc");
Loading content...

Implementors

Loading content...