Skip to content

Commit

Permalink
improve wrap documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Dec 10, 2022
1 parent 7f3a99e commit d955750
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions audio/src/wrap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Wrap an external type to implement [Buf][crate::Buf] and
//! [BufMut][crate::BufMut].
//! This module provides wrappers to pass audio data from crates which
//! use different buffer formats into functions that take [Buf][crate::Buf]
//! or [BufMut][crate::BufMut] without needing to copy data into an intermediate
//! buffer. They may also be useful for incrementally introducing this crate
//! into a codebase that uses a different buffer format.
use crate::slice::Slice;

Expand All @@ -14,7 +17,7 @@ mod dynamic;
#[cfg(feature = "std")]
pub use self::dynamic::Dynamic;

/// Wrap a `value` as an interleaved buffer with the given number of channels.
/// Wrap a slice as an interleaved buffer with the given number of channels.
///
/// Certain interleaved buffers can be used conveniently as implementors of
/// [ReadBuf][crate::ReadBuf] and [WriteBuf][crate::WriteBuf], due to the
Expand Down Expand Up @@ -69,7 +72,7 @@ where
Interleaved::new(value, channels)
}

/// Wrap a `value` as a sequential buffer with the given number of frames. The
/// Wrap a slice as a sequential buffer with the given number of frames. The
/// length of the buffer determines the number of channels it has.
///
/// Unlike [interleaved][interleaved()], wrapped sequential buffers cannot be
Expand All @@ -85,8 +88,8 @@ where
Sequential::new(value, channels)
}

/// Wrap a dynamically sized buffer where each channel must not necessarily be
/// equally sized.
/// Wrap a [Vec] of Vecs or slice of Vecs where each inner Vec is a channel.
/// The channels do not need to be equally sized.
///
/// This should only be used for external types which you have no control over
/// or if you legitimately need a buffer which doesn't have uniformly sized
Expand All @@ -98,7 +101,7 @@ where
/// ```
/// use audio::Buf;
///
/// let buf = [vec![1, 2, 3, 4], vec![5, 6]];
/// let buf = vec![vec![1, 2, 3, 4], vec![5, 6]];
/// let buf = audio::wrap::dynamic(&buf[..]);
/// assert_eq!(buf.channels(), 2);
/// assert_eq!(buf.frames_hint(), Some(4));
Expand Down

0 comments on commit d955750

Please # to comment.