Cobs v0.2.0 Cobs View Source
Elixir implementation of Consistent Overhead Byte Stuffing
Link to this section Summary
Functions
Decode COBS encoded binary (without 0
bytes) into a binary (with 0
bytes)
Decode COBS encoded binary (without 0
bytes) into a binary (with 0
bytes).
Raise an ArgumentError
on invalid input data
Encode a binary (with 0
bytes) into a COBS encoded binary (without 0
bytes)
Encode a binary (with 0
bytes) into a COBS encoded binary (without 0
bytes).
Raise an ArgumentError
on input data exceeding the allowed length (254 bytes)
Link to this section Functions
Decode COBS encoded binary (without 0
bytes) into a binary (with 0
bytes).
Example
iex> Cobs.decode(<<0x03, 0x01, 0x02, 0x02, 0x03>>)
{:ok, <<0x01, 0x02, 0x00, 0x03>>}
Decode COBS encoded binary (without 0
bytes) into a binary (with 0
bytes).
Raise an ArgumentError
on invalid input data.
Example
iex> Cobs.decode!(<<0x03, 0x01, 0x02, 0x02, 0x03>>)
<<0x01, 0x02, 0x00, 0x03>>
Encode a binary (with 0
bytes) into a COBS encoded binary (without 0
bytes).
Example
iex> Cobs.encode(<<0x01, 0x02, 0x00, 0x03>>)
{:ok, <<0x03, 0x01, 0x02, 0x02, 0x03>>}
Encode a binary (with 0
bytes) into a COBS encoded binary (without 0
bytes).
Raise an ArgumentError
on input data exceeding the allowed length (254 bytes)
Example
iex> Cobs.encode!(<<0x01, 0x02, 0x00, 0x03>>)
<<0x03, 0x01, 0x02, 0x02, 0x03>>