View Source ExDicom.ByteAllocator (EX_DICOM v0.1.0)
Provides functionality for allocating byte arrays (binaries) of specified lengths.
Summary
Functions
Creates a new binary of the specified length.
Types
@type byte_array() :: binary()
Functions
@spec alloc(term(), non_neg_integer()) :: {:ok, byte_array()} | {:error, String.t()}
Creates a new binary of the specified length.
Parameters
- source - The source binary to determine the type
- length - The desired length of the new binary in bytes
Returns
{:ok, binary}
- A new binary of the specified length filled with zeros{:error, String.t()}
- Error message if the input type is not supported
Examples
iex> ByteAllocator.alloc(<<1, 2, 3>>, 5)
{:ok, <<0, 0, 0, 0, 0>>}
iex> ByteAllocator.alloc("not a binary", 5)
{:error, "unknown type for byte array"}