7VZF66GPW6DKQB4FU4PTU3CEE32MTYNP4MH6GY4SMICRERO76WDQC def parse(enum) doStream.transform(enum,%__MODULE__{parsers: [magic: bytes(<<0x00, 0x61, 0x73, 0x6D>>)],acc: <<>>},fn_, :stop ->{:halt, :stop}
def new() do%__MODULE__{parsers: [magic: bytes(<<0x00, 0x61, 0x73, 0x6D>>)]}enddef parse_one(<<>>, state) do{nil, state, <<>>}end
case state do%__MODULE__{parsers: []} ->{[{:error, {:no_parsers, chunk}}], :stop}
def parse_one(chunk, state = %__MODULE__{parsers: [{tag, parser} | rest_parsers]}) docase parser.(chunk) do:not_matched ->{{:error, {:not_matched, chunk, tag}}, state, chunk}
:not_matched ->{[{:error, {:not_matched, chunk, tag}}], :stop}endendend)
case result do{:error, _} -> {[result | results] |> Enum.reverse(), state, tail}_ -> parse_all(tail, state, [result | results])end