circbuf – github.com/armon/circbuf Index | Files

package circbuf

import "github.com/armon/circbuf"

Index

Types

type Buffer

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

Buffer implements a circular buffer. It is a fixed size, and new writes overwrite older data, such that for a buffer of size N, for any amount of writes, only the last N bytes are retained.

func NewBuffer

func NewBuffer(size int64) (*Buffer, error)

NewBuffer creates a new buffer of a given size. The size must be greater than 0.

func (*Buffer) Bytes

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

Bytes provides a slice of the bytes written. This slice should not be written to.

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset resets the buffer so it has no content.

func (*Buffer) Size

func (b *Buffer) Size() int64

Size returns the size of the buffer

func (*Buffer) String

func (b *Buffer) String() string

String returns the contents of the buffer as a string

func (*Buffer) TotalWritten

func (b *Buffer) TotalWritten() int64

TotalWritten provides the total number of bytes written

func (*Buffer) Write

func (b *Buffer) Write(buf []byte) (int, error)

Write writes up to len(buf) bytes to the internal ring, overriding older data if necessary.

Source Files

circbuf.go

Version
v0.0.0-20190214190532-5111143e8da2 (latest)
Published
Feb 14, 2019
Platform
js/wasm
Imports
1 packages
Last checked
now

Tools for package owners.