Struct cacache::SyncReader
source · [−]pub struct SyncReader { /* private fields */ }Expand description
File handle for reading data synchronously.
Make sure to call get.check() when done reading
to verify that the extracted data passes integrity
verification.
Implementations
Checks that data read from disk passes integrity checks. Returns the algorithm that was used verified the data. Should be called only after all data has been read from disk.
Example
use std::io::Read;
fn main() -> cacache::Result<()> {
let mut fd = cacache::SyncReader::open("./my-cache", "my-key")?;
let mut str = String::new();
fd.read_to_string(&mut str).expect("Failed to read to string");
// Remember to check that the data you got was correct!
fd.check()?;
Ok(())
}Opens a new synchronous file handle into the cache, looking it up in the
index using key.
Example
use std::io::Read;
fn main() -> cacache::Result<()> {
let mut fd = cacache::SyncReader::open("./my-cache", "my-key")?;
let mut str = String::new();
fd.read_to_string(&mut str).expect("Failed to parse string");
// Remember to check that the data you got was correct!
fd.check()?;
Ok(())
}Opens a new synchronous file handle into the cache, based on its integrity address.
Example
use std::io::Read;
fn main() -> cacache::Result<()> {
let sri = cacache::write_sync("./my-cache", "key", b"hello world")?;
let mut fd = cacache::SyncReader::open_hash("./my-cache", sri)?;
let mut str = String::new();
fd.read_to_string(&mut str).expect("Failed to read to string");
// Remember to check that the data you got was correct!
fd.check()?;
Ok(())
}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 Reader has an efficient read_vectored
implementation. 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
read_buf)Pull some bytes from this source into the specified buffer. Read more
read_buf)Read the exact number of bytes required to fill buf. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Creates an adapter which will chain this stream with another. Read more
Auto Trait Implementations
impl RefUnwindSafe for SyncReader
impl Send for SyncReader
impl Sync for SyncReader
impl Unpin for SyncReader
impl UnwindSafe for SyncReader
Blanket Implementations
Mutably borrows from an owned value. Read more
Reads an unsigned 8 bit integer from the underlying reader. Read more
Reads a signed 8 bit integer from the underlying reader. Read more
Reads an unsigned 16 bit integer from the underlying reader. Read more
Reads a signed 16 bit integer from the underlying reader. Read more
Reads an unsigned 24 bit integer from the underlying reader. Read more
Reads a signed 24 bit integer from the underlying reader. Read more
Reads an unsigned 32 bit integer from the underlying reader. Read more
Reads a signed 32 bit integer from the underlying reader. Read more
Reads an unsigned 48 bit integer from the underlying reader. Read more
Reads a signed 48 bit integer from the underlying reader. Read more
Reads an unsigned 64 bit integer from the underlying reader. Read more
Reads a signed 64 bit integer from the underlying reader. Read more
Reads an unsigned 128 bit integer from the underlying reader. Read more
Reads a signed 128 bit integer from the underlying reader. Read more
Reads an unsigned n-bytes integer from the underlying reader. Read more
Reads a signed n-bytes integer from the underlying reader. Read more
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder,
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder,
Reads an unsigned n-bytes integer from the underlying reader.
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder,
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder,
Reads a signed n-bytes integer from the underlying reader.
Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader. Read more
Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader. Read more
Reads a sequence of unsigned 16 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 32 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 64 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 128 bit integers from the underlying reader. Read more
Reads a sequence of signed 8 bit integers from the underlying reader. Read more
Reads a sequence of signed 16 bit integers from the underlying reader. Read more
Reads a sequence of signed 32 bit integers from the underlying reader. Read more
Reads a sequence of signed 64 bit integers from the underlying reader. Read more
Reads a sequence of signed 128 bit integers from the underlying reader. Read more
Reads a sequence of IEEE754 single-precision (4 bytes) floating point numbers from the underlying reader. Read more
Reads a sequence of IEEE754 double-precision (8 bytes) floating point numbers from the underlying reader. Read more