Struct slice::IoSlice[][src]

pub struct IoSlice<T> where
    T: Seek
{ /* fields omitted */ }

A slice, subset, or view into some object.

IoSlice impls both std::io::Read and std::io::Write when the source implements them (and only one if the source only implements one).

example usage.

use { std::fs::File, slice::IoSlice };


let source = File::open("/home/annie/data.png")?;
let start  = 10;
let length = 1000;


// create a slice into `home/annie/data.png`, consisting of bytes [10 .. 10 + 1000]
// of that file.
//
// `slice` impls both `std::io::Read` and `std::io::Write` because `source`
// does too.
let slice = IoSlice::new(source, start, length);


// use like any other `std::io::Read` or `std::io::Write`:
//
//     slice.read_to_string(...)?;
//     slice.read_exact(...)?;
//     slice.write_all(...)?;
//
//     writeln!(slice, "hello {}", name)?;
//

Methods

impl<T> IoSlice<T> where
    T: Seek
[src]

create a new slice into a specific subset of source.

returns the total length of this io slice.

returns the current position of this slice.

returns the current position of this slice.

Trait Implementations

impl<T: Debug> Debug for IoSlice<T> where
    T: Seek
[src]

Formats the value using the given formatter. Read more

impl<T> Seek for IoSlice<T> where
    T: Seek
[src]

Seek to an offset, in bytes, in a stream. Read more

impl<T> Read for IoSlice<T> where
    T: Read + Seek
[src]

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. 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" adaptor for this instance of Read. Read more

Transforms this Read instance to an [Iterator] over its bytes. Read more

Deprecated since 1.27.0

: Use str::from_utf8 instead: https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples

🔬 This is a nightly-only experimental API. (io)

the semantics of a partial read/write of where errors happen is currently unclear and may change

Transforms this Read instance to an [Iterator] over [char]s. Read more

Creates an adaptor which will chain this stream with another. Read more

Creates an adaptor which will read at most limit bytes from it. Read more

impl<T> Write for IoSlice<T> where
    T: Write + Seek
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Attempts to write an entire buffer into this write. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more

impl<T> Clone for IoSlice<T> where
    T: Clone + Seek
[src]

Important traits for IoSlice<T>

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T> TryClone for IoSlice<T> where
    T: TryClone + Seek
[src]

Auto Trait Implementations

impl<T> Send for IoSlice<T> where
    T: Send

impl<T> Sync for IoSlice<T> where
    T: Sync