ring

package
v0.0.0-...-2e51320 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	*circbuf.Buffer
	// 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

NewBuffer creates a new buffer of a given size. NewBuffer panics if the size is not greater than 0.

func (*Buffer) NewBytesWritten

func (b *Buffer) NewBytesWritten() int64

NewBytesWritten provides the total number of bytes written since the last reset.

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset resets the buffer so it has no content.

func (*Buffer) ResetNewBytesWritten

func (b *Buffer) ResetNewBytesWritten()

ResetNewBytesWritten resets the new bytes written counter.

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.

Jump to

Keyboard shortcuts

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