Struct nameless::OutputTextStream
source · pub struct OutputTextStream { /* private fields */ }
Expand description
An output stream for plain text output.
An OutputTextStream
implements Write
so it supports write
,
write_all
, etc. and can be used anywhere a Write
-implementing
object is needed.
OutputTextStream
is unbuffered (even when it is stdout), so wrapping
it in a std::io::BufWriter
or std::io::LineWriter
is
recommended for performance.
The primary way to construct an OutputTextStream
is to use it as
a type in a kommand
argument or a clap_derive
struct. Command-line
arguments will then be automatically converted into output streams.
Currently supported syntaxes include:
- Names starting with
file:
are interpreted as local filesystem URLs providing paths to files to open. - “-” is interpreted as standard output.
- “(…)” runs a command with a pipe to the child process’ stdin, on platforms whch support it.
- Names which don’t parse as URLs are interpreted as plain local
filesystem paths. To force a string to be interpreted as a plain local
path, arrange for it to begin with
./
or/
.
Programs using OutputTextStream
as an argument should avoid using
std::io::stdout
, std::println
, or anything else which uses standard
output implicitly.
Implementations§
source§impl OutputTextStream
impl OutputTextStream
sourcepub fn write_pseudonym(&mut self, pseudonym: &Pseudonym) -> Result<()>
pub fn write_pseudonym(&mut self, pseudonym: &Pseudonym) -> Result<()>
Write the given Pseudonym
to the output stream.
sourcepub fn pseudonym(&self) -> Pseudonym
pub fn pseudonym(&self) -> Pseudonym
Return a Pseudonym
which encapsulates this stream’s name (typically
its filesystem path or its URL). This allows it to be written to an
OutputByteStream
while otherwise remaining entirely opaque.
sourcepub fn media_type(&self) -> &MediaType
pub fn media_type(&self) -> &MediaType
If the output stream metadata implies a particular media type, also known as MIME type, return it. Otherwise default to “text/plain; charset=utf-8”.
Trait Implementations§
source§impl Bufferable for OutputTextStream
impl Bufferable for OutputTextStream
source§impl Debug for OutputTextStream
impl Debug for OutputTextStream
source§impl Drop for OutputTextStream
impl Drop for OutputTextStream
source§impl Write for OutputTextStream
impl Write for OutputTextStream
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
write_all_vectored
)source§impl WriteLayered for OutputTextStream
impl WriteLayered for OutputTextStream
source§impl WriteStr for OutputTextStream
impl WriteStr for OutputTextStream
source§impl WriteTerminal for OutputTextStream
impl WriteTerminal for OutputTextStream
source§fn color_support(&self) -> TerminalColorSupport
fn color_support(&self) -> TerminalColorSupport
source§fn color_preference(&self) -> bool
fn color_preference(&self) -> bool
NO_COLOR
environment variable where applicable.source§fn is_output_terminal(&self) -> bool
fn is_output_terminal(&self) -> bool
source§fn color_default(&self) -> bool
fn color_default(&self) -> bool
source§impl WriteText for OutputTextStream
impl WriteText for OutputTextStream
source§fn write_text(&mut self, buf: &TextStr) -> Result<()>
fn write_text(&mut self, buf: &TextStr) -> Result<()>
WriteStr::write_str
but writes from a TextStr
.source§fn write_text_substr(&mut self, buf: &TextSubstr) -> Result<(), Error>
fn write_text_substr(&mut self, buf: &TextSubstr) -> Result<(), Error>
WriteStr::write_str
but writes from a TextSubstr
.impl Terminal for OutputTextStream
Auto Trait Implementations§
impl Freeze for OutputTextStream
impl !RefUnwindSafe for OutputTextStream
impl Send for OutputTextStream
impl Sync for OutputTextStream
impl Unpin for OutputTextStream
impl !UnwindSafe for OutputTextStream
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
source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self
file descriptor. Read more