package buffer

import "github.com/Azure/go-amqp/internal/buffer"

Index

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is similar to bytes.Buffer but specialized for this module. The zero-value is an empty buffer ready for use.

func New

func New(b []byte) *Buffer

New creates a new Buffer with b as its initial contents. Use this to start reading from b.

func (*Buffer) Append

func (b *Buffer) Append(p []byte)

Append appends p to the existing buffer.

func (*Buffer) AppendByte

func (b *Buffer) AppendByte(bb byte)

AppendByte appends bb to the existing buffer.

func (*Buffer) AppendString

func (b *Buffer) AppendString(s string)

AppendString appends s to the existing buffer.

func (*Buffer) AppendUint16

func (b *Buffer) AppendUint16(n uint16)

AppendUint16 appends n as two bytes in big-endian encoding.

func (*Buffer) AppendUint32

func (b *Buffer) AppendUint32(n uint32)

AppendUint32 appends n as four bytes in big-endian encoding.

func (*Buffer) AppendUint64

func (b *Buffer) AppendUint64(n uint64)

AppendUint64 appends n as eight bytes in big-endian encoding.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns a slice containing the unread portion of the buffer.

func (*Buffer) Detach

func (b *Buffer) Detach() []byte

Detach returns the underlying byte slice, disassociating it from the buffer.

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the number of bytes of the unread portion of the buffer.

func (*Buffer) Next

func (b *Buffer) Next(n int64) ([]byte, bool)

Next returns a slice containing the next n bytes from the buffer and advances the buffer. If there are fewer than n bytes in the buffer, Next returns the remaining contents, false. The slice is only valid until the next call to a read or write method.

func (*Buffer) PeekByte

func (b *Buffer) PeekByte() (byte, error)

PeekByte returns the next byte in the buffer without advancing the buffer. If there are insufficient bytes, an error is returned.

func (*Buffer) ReadByte

func (b *Buffer) ReadByte() (byte, error)

ReadByte reads one byte from the buffer and advances the buffer. If there are insufficient bytes, an error is returned.

func (*Buffer) ReadFromOnce

func (b *Buffer) ReadFromOnce(r io.Reader) error

ReadFromOnce reads from r to populate the buffer. Reads up to cap - len of the underlying slice.

func (*Buffer) ReadUint16

func (b *Buffer) ReadUint16() (uint16, error)

ReadUint16 reads two bytes from the buffer and decodes them as big-endian into a uint16. Advances the buffer by two. If there are insufficient bytes, an error is returned.

func (*Buffer) ReadUint32

func (b *Buffer) ReadUint32() (uint32, error)

ReadUint32 reads four bytes from the buffer and decodes them as big-endian into a uint32. Advances the buffer by four. If there are insufficient bytes, an error is returned.

func (*Buffer) ReadUint64

func (b *Buffer) ReadUint64() (uint64, error)

ReadUint64 reads eight bytes from the buffer and decodes them as big-endian into a uint64. Advances the buffer by eight. If there are insufficient bytes, an error is returned.

func (*Buffer) Reclaim

func (b *Buffer) Reclaim()

Reclaim moves the unread portion of the buffer to the beginning of the underlying slice and resets the index.

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset resets the buffer to be empty but retains the underlying storage for use by future writes.

func (*Buffer) Size

func (b *Buffer) Size() int

Size returns the number of bytes that have been read from this buffer. This implies a minimum size of the underlying buffer.

func (*Buffer) Skip

func (b *Buffer) Skip(n int)

Skip advances the buffer by n bytes.

Source Files

buffer.go

Version
v1.4.0 (latest)
Published
Feb 19, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
5 days ago

Tools for package owners.