The framing of Yjs updates in a .updates stream, as lib0's
writeVarUint8Array writes it and the reference y-durable-streams
provider reads it: each update is its byte size as a varuint, then the
update. Frames are concatenated, so a batch of frames is itself valid
framing.
A varuint is little-endian base 128: 7 bits per byte, low groups first, the high bit set on every byte but the last.
Summary
Functions
Frames one update.
Frames several updates into one binary.
Splits concatenated frames into their updates. {:error, :truncated} if
the binary ends inside a frame, {:error, :invalid} if a length does not
fit in 53 bits (lib0's limit).
Decodes a varuint at the start of binary: {:ok, n, rest}, or an error
as for parse/1.
Encodes a non-negative integer as a varuint.
Functions
Frames one update.
Frames several updates into one binary.
Splits concatenated frames into their updates. {:error, :truncated} if
the binary ends inside a frame, {:error, :invalid} if a length does not
fit in 53 bits (lib0's limit).
@spec read_varuint(binary()) :: {:ok, non_neg_integer(), binary()} | {:error, :truncated | :invalid}
Decodes a varuint at the start of binary: {:ok, n, rest}, or an error
as for parse/1.
@spec varuint(non_neg_integer()) :: binary()
Encodes a non-negative integer as a varuint.