pub struct ShellWriter<W: Write> { /* private fields */ }
Expand description

A writer of var=value pairs.

See ShellWriter::new().

Implementations§

Create a new ShellWriter. The prefix will be prepended anytime a var is outputted, e.g. prefixvar=value.

Generally, you will want to use this like:

use git_status_vars::ShellWriter;
ShellWriter::default().group("group").write_var("var", "value");
// or...
let mut buffer: Vec<u8> = vec![];
ShellWriter::new(&mut buffer, "").group("group").write_var("var", "value");
assert_eq!(buffer, b"group_var=value\n");

Write var=value. value will be turned into a string, then quoted for safe shell insertion. var will be assumed to be a valid name for a shell variable.

Write var=value. value will be formatted into a string using Debug, then quoted for safe shell insertion. var will be assumed to be a valid name for a shell variable.

Write an object with the ShellVars trait. Mostly used with Self::group() and Self::group_n().

Generate a sub-writer with this group name. Example output:

prefix_group_var=value

Generate a sub-writer with this group name and number. Example output:

prefix_groupN_var=value

Create a new ShellWriter for io::stdout() and a prefix.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Create a new ShellWriter for io::stdout() and no prefix.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.