Struct clio::CachedInput [−][src]
pub struct CachedInput { /* fields omitted */ }
Expand description
A struct that contains all the connents of a command line input stream, either std in or a file
It is designed to be used with the structopt
crate when taking a file name as an
argument to CLI app
use structopt::StructOpt;
use clio::CachedInput;
#[derive(StructOpt)]
struct Opt {
/// path to file, use '-' for stdin
#[structopt(parse(try_from_os_str = CachedInput::try_from_os_str))]
input_file: CachedInput,
}
Implementations
Reads all the data from an input into memmory and stores it in a new CachedInput.
Useful if you want to use the input twice (see reset), or need to know the size.
Contructs a new input either by opening the file or for ‘-’ returning stdin. The error is converted to a OsString so that stuctopt can show it to the user.
Returns the size of the file in bytes.
Examples
let file = clio::CachedInput::try_from_os_str("foo.txt".as_ref()).unwrap();
assert_eq!(3, file.len());
Returns a boolean saying if the file is empty
Examples
let file = clio::CachedInput::try_from_os_str("foo.txt".as_ref()).unwrap();
assert_eq!(true, file.is_empty());
Trait Implementations
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read
, except that it reads into a slice of buffers. Read more
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
read_initializer
)Determines if this Read
er can work with buffers of uninitialized
memory. Read more
Read all bytes until EOF in this source, placing them into buf
. Read more
Read all bytes until EOF in this source, appending them to buf
. Read more
Read the exact number of bytes required to fill buf
. Read more
Creates a “by reference” adapter for this instance of Read
. Read more
Creates an adapter which will chain this stream with another. Read more