Decode the protobuf wire format in Gleam!
3

Configure Feed

Select the types of activity you want to include in your feed.

Rename `DecodeError` to `ParseError`

Gavin Morrow (Sep 20, 2025, 12:25 PM EDT) 3a01f88c f1f46a0e

+4 -4
+4 -4
src/protobuf_decode_gleam.gleam
··· 12 12 pub fn parse( 13 13 from bits: BitArray, 14 14 using decoder: Decoder(t), 15 - ) -> Result(t, DecodeError) { 15 + ) -> Result(t, ParseError) { 16 16 use data <- result.try(read_fields(bits, [])) 17 17 decode.run(data, decoder) |> result.map_error(UnableToDecode) 18 18 } 19 19 20 - pub type DecodeError { 20 + pub type ParseError { 21 21 UnknownWireType(Int) 22 22 InvalidVarInt(leftover_bits: BitArray, acc: BitArray) 23 23 InvalidFixed(size: Int, bits: BitArray) ··· 25 25 UnableToDecode(List(decode.DecodeError)) 26 26 } 27 27 28 - fn read_fields(bits: BitArray, acc: List(Field)) -> Result(Dynamic, DecodeError) { 28 + fn read_fields(bits: BitArray, acc: List(Field)) -> Result(Dynamic, ParseError) { 29 29 case bits { 30 30 <<>> -> 31 31 acc ··· 40 40 } 41 41 42 42 type DecodeResult(t) = 43 - Result(t, DecodeError) 43 + Result(t, ParseError) 44 44 45 45 type Parsed(t) { 46 46 Parsed(value: t, rest: BitArray)