Libp2p.Yamux.Frame (libp2p_elixir v0.9.0)

Yamux frame encode/decode per third_party/libp2p_specs/yamux/README.md.

Header (12 bytes, big-endian / network order):

  • Version (u8) (always 0)
  • Type (u8) (data=0, window_update=1, ping=2, go_away=3)
  • Flags (u16)
  • StreamID (u32)
  • Length (u32)

For :data frames, Length is the number of bytes following the header. For all other frame types, Length is an in-header value (no payload bytes).

Summary

Functions

Decode a single yamux frame from bin. Returns {frame, rest} or :more if incomplete.

Types

t()

@type t() :: %Libp2p.Yamux.Frame{
  data: binary(),
  flags: non_neg_integer(),
  length: non_neg_integer(),
  stream_id: non_neg_integer(),
  type: type()
}

type()

@type type() :: :data | :window_update | :ping | :go_away

Functions

decode_frames(bin, acc \\ [])

@spec decode_frames(binary(), [t()]) :: {[t()], binary()}

decode_one(bin)

@spec decode_one(binary()) :: {t(), binary()} | :more

Decode a single yamux frame from bin. Returns {frame, rest} or :more if incomplete.

encode(f)

@spec encode(t()) :: iodata()