diskio

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0, GPL-2.0, GPL-3.0-or-later, + 1 more Imports: 8 Imported by: 0

Documentation

Overview

Package diskio implements utilities for working with disk I/O.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBufferedFile

func NewBufferedFile[A ~int64](ctx context.Context, file File[A], blockSize A, cacheSize int) *bufferedFile[A]

func NewStatefulFile

func NewStatefulFile[A ~int64](file File[A]) *statefulFile[A]

Types

type File

type File[A ~int64] interface {
	Name() string
	Size() A
	io.Closer
	ReaderAt[A]
	WriteAt(p []byte, off A) (n int, err error)
}

type OSFile

type OSFile[A ~int64] struct {
	*os.File
}

func (*OSFile[A]) ReadAt

func (f *OSFile[A]) ReadAt(dat []byte, paddr A) (int, error)

func (*OSFile[A]) Size

func (f *OSFile[A]) Size() A

func (*OSFile[A]) WriteAt

func (f *OSFile[A]) WriteAt(dat []byte, paddr A) (int, error)

type ReaderAt

type ReaderAt[A ~int64] interface {
	ReadAt(p []byte, off A) (n int, err error)
}

type Ref

type Ref[A ~int64, T any] struct {
	File File[A]
	Addr A
	Data T
}

func (*Ref[A, T]) Read

func (r *Ref[A, T]) Read() error

func (*Ref[A, T]) Write

func (r *Ref[A, T]) Write() error

type Sequence

type Sequence[K ~int64 | ~int, V any] interface {
	SeqLen() K
	// Get the value at 'pos' in the sequence.  Positions start at
	// 0 and increment naturally.  It is invalid to call
	// SeqGet(pos) with a pos that is >= SeqLen().
	SeqGet(pos K) V
}

type SliceSequence

type SliceSequence[K ~int64 | ~int, V any] []V

func (SliceSequence[K, V]) SeqGet

func (s SliceSequence[K, V]) SeqGet(i K) V

func (SliceSequence[K, V]) SeqLen

func (s SliceSequence[K, V]) SeqLen() K

type StringSequence

type StringSequence[K ~int64 | ~int] string

func (StringSequence[K]) SeqGet

func (s StringSequence[K]) SeqGet(i K) byte

func (StringSequence[K]) SeqLen

func (s StringSequence[K]) SeqLen() K

Jump to

Keyboard shortcuts

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