quicvarint

package
v0.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 3 Imported by: 92

Documentation

Index

Constants

View Source
const (
	// Min is the minimum value allowed for a QUIC varint.
	Min = 0

	// Max is the maximum allowed value for a QUIC varint (2^62-1).
	Max = maxVarInt8
)

taken from the QUIC draft

Variables

This section is empty.

Functions

func Append

func Append(b []byte, i uint64) []byte

Append appends i in the QUIC varint format.

func AppendWithLen

func AppendWithLen(b []byte, i uint64, length int) []byte

AppendWithLen append i in the QUIC varint format with the desired length.

func Len

func Len(i uint64) int

Len determines the number of bytes that will be needed to write the number i.

func Parse added in v0.44.0

func Parse(b []byte) (uint64, int, error)

Parse reads a number in the QUIC varint format. It returns the number of bytes consumed.

func Read

func Read(r io.ByteReader) (uint64, error)

Read reads a number in the QUIC varint format from r.

Types

type Reader

type Reader interface {
	io.ByteReader
	io.Reader
}

Reader implements both the io.ByteReader and io.Reader interfaces.

func NewReader

func NewReader(r io.Reader) Reader

NewReader returns a Reader for r. If r already implements both io.ByteReader and io.Reader, NewReader returns r. Otherwise, r is wrapped to add the missing interfaces.

type Writer

type Writer interface {
	io.ByteWriter
	io.Writer
}

Writer implements both the io.ByteWriter and io.Writer interfaces.

func NewWriter

func NewWriter(w io.Writer) Writer

NewWriter returns a Writer for w. If r already implements both io.ByteWriter and io.Writer, NewWriter returns w. Otherwise, w is wrapped to add the missing interfaces.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL