ArtNet. Misc
(ArtNet v0.1.0)
View Source
Summary
Functions
Pads a binary with zero bytes to reach the specified length.
Functions
@spec pad_binary(binary(), pos_integer(), non_neg_integer()) :: binary()
Pads a binary with zero bytes to reach the specified length.
If min_length is given, padding is only applied when the binary size
is at least min_length. Otherwise, the binary is returned as-is.
Parameters
binary- the binary to padlength- target size after paddingmin_length- minimum size required to trigger padding (default:0)
Examples
iex> ArtNet.Misc.pad_binary(<<1, 2>>, 5)
<<1, 2, 0, 0, 0>>
iex> ArtNet.Misc.pad_binary(<<1, 2, 3, 4, 5>>, 5)
<<1, 2, 3, 4, 5>>
iex> ArtNet.Misc.pad_binary(<<1>>, 5, 2)
<<1>>