Struct nameless::InputByteStream
source · pub struct InputByteStream { /* private fields */ }
Expand description
An input stream for binary input.
An InputByteStream
implements Read
so it supports read
,
read_to_end
, read_to_str
, etc. and can be used anywhere a
Read
-implementing object is needed.
InputByteStream
is unbuffered (even when it is stdin), so wrapping
it in a std::io::BufReader
is recommended for performance and
ease of use.
The primary way to construct an InputByteStream
is to use it as
a type in a kommand
argument or clap_derive
struct. Command-line
arguments will then be automatically converted into input streams.
Currently supported syntaxes include:
- Names starting with
https:
orhttp:
, which are interpreted as URLs to open. - Names starting with
data:
are interpreted as data URLs proving the data in their payload. - Names starting with
file:
are interpreted as local filesystem URLs providing paths to files to open. - “-” is interpreted as standard input.
- “(…)” runs a command with a pipe from the child process’ stdout, 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/
.
Implementations§
source§impl InputByteStream
impl InputByteStream
sourcepub fn media_type(&self) -> &MediaType
pub fn media_type(&self) -> &MediaType
If the input stream metadata implies a particular media type, also known as MIME type, return it. Many input streams know their type, though some do not. This is strictly based on available metadata, and not on examining any of the contents of the stream, and there’s no guarantee the contents are valid.
sourcepub fn initial_size(&self) -> Option<u64>
pub fn initial_size(&self) -> Option<u64>
Return the initial size of the stream, in bytes. This is strictly based on available metadata, and not on examining any of the contents of the stream, and the stream could end up being shorter or longer if the source is concurrently modified.
Trait Implementations§
source§impl Bufferable for InputByteStream
impl Bufferable for InputByteStream
source§impl Debug for InputByteStream
impl Debug for InputByteStream
source§impl Read for InputByteStream
impl Read for InputByteStream
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
buf
. Read moresource§fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
buf
. Read moresource§fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moresource§impl ReadLayered for InputByteStream
impl ReadLayered for InputByteStream
source§fn read_with_status(&mut self, buf: &mut [u8]) -> Result<(usize, Status)>
fn read_with_status(&mut self, buf: &mut [u8]) -> Result<(usize, Status)>
Read::read
, but also returns a Status
.source§fn read_vectored_with_status(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<(usize, Status)>
fn read_vectored_with_status( &mut self, bufs: &mut [IoSliceMut<'_>] ) -> Result<(usize, Status)>
Read::read_vectored
, but also returns a Status
.source§fn read_exact_using_status(&mut self, buf: &mut [u8]) -> Result<Status, Error>
fn read_exact_using_status(&mut self, buf: &mut [u8]) -> Result<Status, Error>
Read::read_exact
, but uses read_with_status
to avoid
performing an extra read
at the end.source§fn minimum_buffer_size(&self) -> usize
fn minimum_buffer_size(&self) -> usize
Auto Trait Implementations§
impl Freeze for InputByteStream
impl !RefUnwindSafe for InputByteStream
impl Send for InputByteStream
impl Sync for InputByteStream
impl Unpin for InputByteStream
impl !UnwindSafe for InputByteStream
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