Function little::stream::seek_and_buf_copy [] [src]

pub fn seek_and_buf_copy<I, O>(loc: u64, len: u64, buf: &mut [u8], input: &mut I, output: &mut O) -> Result<u64, Error> where I: Read + Seek, O: Write

Copy len bytes from reader to writer using buf from specified loc position.

Example

use little::stream;
use std::io::Cursor;

let data: &[u8] = b"it is interesting";
let mut reader = Cursor::new(data);
let mut writer = Vec::new();

let mut buf = [0; 4]; // note the buffer is smaller
stream::seek_and_buf_copy(3, 5, &mut buf, &mut reader, &mut writer).unwrap();

assert_eq!("is in", String::from_utf8_lossy(&writer[..]));