Skip to content

Wireform.Core.Decoder

Packagewireform-coreModuleWireform.Core.Decoder

Low-level decoder primitives. Most users go through the format-specific wrappers (Wireform.Proto.Decode, Wireform.MsgPack.Decode, …); this module is the plumbing.

Synopsis

  • getVarint :: Decoder Word64
  • getText :: Int -> Decoder Text
  • withTag :: Decoder Word64 -> (Word64 -> Decoder a) -> Decoder a

getVarint :: Decoder Word64Source

Decode an LEB128-encoded varint. Allocation-free on the hot path.

getText :: Int -> Decoder TextSource

Read n bytes and validate as UTF-8.

withTag :: Decoder Word64 -> (Word64 -> Decoder a) -> Decoder aSource

CPS-style tag dispatch. Read a wire tag, then run a continuation that knows what to do with each value (statically inlined by GHC).