Struct git_status_vars::ShellWriter
source · 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> !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