Need help trying to parse a complex binary protocol, getting: Warning: BINARY CREATED: binary is returned from the function

Since you return Rest a binary has to be created.

The returned binary will be optimized to be a sub-binary (i.e. pointer into the original binary) by the compiler so there will be no copy of the data.

Edit: This exact scenario is described in the docs here: Erlang -- Constructing and Matching Binaries