spin

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 4 Imported by: 1

README

spin

Ring buffer implementation in go

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 is the ring buffer implementation.

func New

func New() *Buffer

New creates a new ring buffer.

func (*Buffer) Close

func (b *Buffer) Close() error

Close closes the buffer.

func (*Buffer) Iterate

func (b *Buffer) Iterate(f func(p []byte) (int, bool, error)) (int64, error)

Iterate implements iterator over available data. It makes all the available data to the iterator, then it should say how many bytes has been used and if iterator is interested in receiving more data.

func (*Buffer) Read

func (b *Buffer) Read(p []byte) (int, error)

Read reads bytes from the buffer.

func (*Buffer) ReadByte

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

ReadByte reads one byte from the buffer.

func (*Buffer) ReadFrom

func (b *Buffer) ReadFrom(r io.Reader) (int64, error)

ReadFrom copies the content of the provided reader to the ring buffer.

func (*Buffer) Write

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

Write writes bytes to the ring buffer.

func (*Buffer) WriteByte

func (b *Buffer) WriteByte(v byte) error

WriteByte writes one byte to the buffer.

func (*Buffer) WriteTo

func (b *Buffer) WriteTo(w io.Writer) (int64, error)

WriteTo copies the content of the ring buffer to the provided writer.

Jump to

Keyboard shortcuts

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