pub struct ShellWriter<W: Write> { /* private fields */ }Expand description
A writer of var=value pairs.
See ShellWriter::new().
Implementations§
Source§impl<W: Write> ShellWriter<W>
impl<W: Write> ShellWriter<W>
Sourcepub fn new<P: Display>(writer: W, prefix: P) -> Self
pub fn new<P: Display>(writer: W, prefix: P) -> Self
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");Sourcepub fn write_var<K: Display, V: Display>(&self, var: K, value: V)
pub fn write_var<K: Display, V: Display>(&self, var: K, value: V)
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.
Sourcepub fn write_var_debug<K: Display, V: Debug>(&self, var: K, value: V)
pub fn write_var_debug<K: Display, V: Debug>(&self, var: K, value: V)
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.
Sourcepub fn write_vars<V: ShellVars>(&self, vars: &V)
pub fn write_vars<V: ShellVars>(&self, vars: &V)
Write an object with the ShellVars trait. Mostly used with
Self::group() and Self::group_n().
Source§impl ShellWriter<Stdout>
impl ShellWriter<Stdout>
Sourcepub fn with_prefix<P: Display>(prefix: P) -> Self
pub fn with_prefix<P: Display>(prefix: P) -> Self
Create a new ShellWriter for io::stdout() and a prefix.
Trait Implementations§
Source§impl<W: Clone + Write> Clone for ShellWriter<W>
impl<W: Clone + Write> Clone for ShellWriter<W>
Source§fn clone(&self) -> ShellWriter<W>
fn clone(&self) -> ShellWriter<W>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ShellWriter<Stdout>
impl Default for ShellWriter<Stdout>
Source§fn default() -> Self
fn default() -> Self
Create a new ShellWriter for io::stdout() and no prefix.
Auto Trait Implementations§
impl<W> Freeze for ShellWriter<W>
impl<W> !RefUnwindSafe for ShellWriter<W>
impl<W> !Send for ShellWriter<W>
impl<W> !Sync for ShellWriter<W>
impl<W> Unpin for ShellWriter<W>
impl<W> !UnwindSafe for ShellWriter<W>
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