# Struct alsa::pcm::IO [−] [src]

    pub struct IO<'a, S: Copy>(_, _);

Sample format dependent struct for reading from and writing data to a `PCM`. Also implements `std::io::Read` and `std::io::Write`.

Note: Only one IO object is allowed in scope at a time (for mmap safety).

## Methods

### `impl<'a, S: Copy> IO<'a, S>`
[src]

#### `fn writei(&self, buf: &[S]) -> Result<usize>`

On success, returns number of frames written. (Multiply with number of channels to get number of items in buf successfully written.)

#### `fn readi(&self, buf: &mut [S]) -> Result<usize>`

On success, returns number of frames read. (Multiply with number of channels to get number of items in buf successfully read.)

#### `fn mmap<F: FnOnce(&mut [S]) -> usize>(
&self,
frames: usize,
func: F
) -> Result<usize>`

Wrapper around snd_pcm_mmap_begin and snd_pcm_mmap_commit.

You can read/write into the sound card's buffer during the call to the closure. According to alsa-lib docs, you should call avail_update before calling this function.

All calculations are in frames, i e, the closure should return number of frames processed. Also, there might not be as many frames to read/write as requested, and there can even be an empty buffer supplied to the closure.

Note: This function works only with interleaved access mode.

## Trait Implementations

### `impl<'a, S: Copy> Drop for IO<'a, S>`
[src]

#### `fn drop(&mut self)`

A method called when the value goes out of scope. Read more

### `impl<'a, S: Copy> Read for IO<'a, S>`
[src]

#### `fn read(&mut self, buf: &mut [u8]) -> Result<usize>`

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

#### `unsafe fn initializer(&self) -> Initializer`

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

Determines if this `Read`er can work with buffers of uninitialized memory. Read more

#### `fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>`
1.0.0

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

#### `fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>`
1.0.0

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

#### `fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>`
1.6.0

Read the exact number of bytes required to fill `buf`. Read more

#### `fn by_ref(&mut self) -> &mut Self`
1.0.0

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

#### `fn bytes(self) -> Bytes<Self>`
1.0.0

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

#### `fn chars(self) -> Chars<Self>`

🔬 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

#### `fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,`
1.0.0

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

#### `fn take(self, limit: u64) -> Take<Self>`
1.0.0

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

### `impl<'a, S: Copy> Write for IO<'a, S>`
[src]

#### `fn write(&mut self, buf: &[u8]) -> Result<usize>`

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

#### `fn flush(&mut self) -> Result<()>`

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

#### `fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>`
1.0.0

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

#### `fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>`
1.0.0

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

#### `fn by_ref(&mut self) -> &mut Self`
1.0.0

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

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)