Struct nameless::OutputByteStream
source · pub struct OutputByteStream { /* private fields */ }
Expand description
An output stream for binary output.
An OutputByteStream
implements Write
so it supports write
,
write_all
, etc. and can be used anywhere a Write
-implementing
object is needed.
OutputByteStream
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 OutputByteStream
is to use it as
a type in a kommand
argument or 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 OutputByteStream
as an argument should avoid using
std::io::stdout
, std::println
, or anything else which uses standard
output implicitly.
Implementations§
source§impl OutputByteStream
impl OutputByteStream
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. Some output streams know their type, though many do not.
Trait Implementations§
source§impl Bufferable for OutputByteStream
impl Bufferable for OutputByteStream
source§impl Debug for OutputByteStream
impl Debug for OutputByteStream
source§impl Write for OutputByteStream
impl Write for OutputByteStream
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 OutputByteStream
impl WriteLayered for OutputByteStream
Auto Trait Implementations§
impl Freeze for OutputByteStream
impl !RefUnwindSafe for OutputByteStream
impl Send for OutputByteStream
impl Sync for OutputByteStream
impl Unpin for OutputByteStream
impl !UnwindSafe for OutputByteStream
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