Struct rotary::io::Read[][src]

pub struct Read<B> { /* fields omitted */ }

Make a buffer into a read adapter that implements ReadBuf.

Examples

use rotary::{Buf as _, BufMut as _, WriteBuf as _};
use rotary::io;

let from = rotary::interleaved![[1.0f32, 2.0f32, 3.0f32, 4.0f32]; 2];
let mut to = rotary::interleaved![[0.0f32; 4]; 2];

let mut to = io::ReadWrite::new(to);

io::copy_remaining(io::Read::new((&from).skip(2).limit(1)), &mut to);
io::copy_remaining(io::Read::new((&from).limit(1)), &mut to);

assert_eq! {
    to.as_ref().as_slice(),
    &[3.0, 3.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0],
};

Implementations

impl<B> Read<B> where
    B: ExactSizeBuf
[src]

pub fn new(buf: B) -> Self[src]

Construct a new read adapter.

pub fn as_ref(&self) -> &B[src]

Access the underlying buffer.

Examples

use rotary::{Buf as _, WriteBuf as _};
use rotary::{io, wrap};

let buffer: rotary::Interleaved<i16> = rotary::interleaved![[1, 2, 3, 4]; 4];
let mut buffer = io::Read::new(buffer);

io::copy_remaining(&mut buffer, wrap::interleaved(&mut [0i16; 16][..], 4));

assert_eq!(buffer.as_ref().channels(), 4);

pub fn as_mut(&mut self) -> &mut B[src]

Access the underlying buffer mutably.

Examples

use rotary::{Buf as _, WriteBuf as _, ExactSizeBuf as _};
use rotary::{io, wrap};

let buffer: rotary::Interleaved<i16> = rotary::interleaved![[1, 2, 3, 4]; 4];
let mut buffer = io::Read::new(buffer);

io::copy_remaining(&mut buffer, wrap::interleaved(&mut [0i16; 16][..], 4));

buffer.as_mut().resize_channels(2);

assert_eq!(buffer.channels(), 2);

pub fn into_inner(self) -> B[src]

Convert into the underlying buffer.

Examples

use rotary::{Buf as _, WriteBuf as _};
use rotary::{io, wrap};

let buffer: rotary::Interleaved<i16> = rotary::interleaved![[1, 2, 3, 4]; 4];
let mut buffer = io::Read::new(buffer);

io::copy_remaining(&mut buffer, wrap::interleaved(&mut [0i16; 16][..], 4));

let buffer = buffer.into_inner();

assert_eq!(buffer.channels(), 4);

Trait Implementations

impl<B, T> Buf<T> for Read<B> where
    B: Buf<T>, 
[src]

impl<B> ExactSizeBuf for Read<B> where
    B: ExactSizeBuf
[src]

impl<B> ReadBuf for Read<B>[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for Read<B> where
    B: RefUnwindSafe

impl<B> Send for Read<B> where
    B: Send

impl<B> Sync for Read<B> where
    B: Sync

impl<B> Unpin for Read<B> where
    B: Unpin

impl<B> UnwindSafe for Read<B> where
    B: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.