Struct rotary::io::Write[][src]

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

Make a mutable buffer into a write adapter that implements WriteBuf.

Examples

use rotary::{Buf as _, BufMut as _, ReadBuf as _, WriteBuf as _};
use rotary::io::{Read, Write, copy_remaining};

let from = rotary::interleaved![[1.0f32, 2.0f32, 3.0f32, 4.0f32]; 2];
let to = rotary::interleaved![[0.0f32; 4]; 2];
let mut to = Write::new(to);
let mut from = Read::new(from.skip(2));

assert_eq!(to.remaining_mut(), 4);
copy_remaining(from, &mut to);
assert_eq!(to.remaining_mut(), 2);

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

Implementations

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

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

Construct a new write adapter.

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

Access the underlying buffer.

Examples

use rotary::Buf as _;
use rotary::io;

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

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

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 _;
use rotary::io;

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

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

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 _;
use rotary::io;

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

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

let buffer = buffer.into_inner();

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

Trait Implementations

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

impl<B, T> BufMut<T> for Write<B> where
    B: BufMut<T>, 
[src]

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

impl<B> WriteBuf for Write<B>[src]

fn remaining_mut(&self) -> usize[src]

Remaining number of frames available.

Auto Trait Implementations

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

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

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

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

impl<B> UnwindSafe for Write<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.