ring

package
v0.0.0-...-5db00e0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

NewBuffer creates a new buffer of a given size. NewBuffer panics if the size is not 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) ResetTotalWritten

func (b *Buffer) ResetTotalWritten()

ResetTotalWritten resets the TotalWritten count.

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.

Jump to

Keyboard shortcuts

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