wavex v0.9.3 Wavex.Utils
Miscellaneous utilities.
Link to this section Summary
Functions
Read max_bytes
bytes, or until a null byte is encountered
Verify a FourCC (four character code)
Link to this section Functions
Link to this function
read_until_null(max_bytes, binary)
read_until_null(non_neg_integer(), binary()) :: {:ok, binary(), binary()} | {:error, Wavex.Error.UnexpectedEOF.t()}
Read max_bytes
bytes, or until a null byte is encountered.
Examples
iex> Wavex.Utils.read_until_null(5, <<1, 2, 3, 4, 5, 6, 7, 8, 9>>)
{:ok, <<1, 2, 3, 4, 5>>, <<6, 7, 8, 9>>}
iex> Wavex.Utils.read_until_null(5, <<1, 2, 3, 4, 5, 6, 7, 8, 9>>)
{:ok, <<1, 2, 3, 4, 5>>, <<6, 7, 8, 9>>}
iex> Wavex.Utils.read_until_null(5, <<1, 2, 3>>)
{:error, %Wavex.Error.UnexpectedEOF{}}
Link to this function
verify_four_cc(arg1, arg2)
verify_four_cc(<<_::32>>, <<_::32>>) :: :ok | {:error, Wavex.Error.UnexpectedFourCC.t()}
Verify a FourCC (four character code).
Examples
iex> Wavex.Utils.verify_four_cc("RIFF", "RIFF")
:ok
iex> Wavex.Utils.verify_four_cc("RIFX", "RIFF")
{:error, %UnexpectedFourCC{expected: "RIFF", actual: "RIFX"}}