fssafe

package
v0.0.0-...-ee8abc8 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicLoaderSaver

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

BasicLoaderSaver provides the minimum functionality for a LoaderSaver.

func NewFileSystemLoaderSaver

func NewFileSystemLoaderSaver(path string) *BasicLoaderSaver

NewFileSystemLoaderSaver builds a file system loader/saver that creates single file backups prior to writing and attempts to make saves atomic by writing data to a temporary file, which is then moved in to replace the save file.

This returns a LoaderSaver.

func (*BasicLoaderSaver) Loader

func (ls *BasicLoaderSaver) Loader() (io.ReadCloser, error)

Loader provides a io.ReadCloser for reading a save file.

func (*BasicLoaderSaver) LoaderFunc

func (ls *BasicLoaderSaver) LoaderFunc() Loader

LoaderFunc returns the Loader function used.

func (*BasicLoaderSaver) Saver

func (ls *BasicLoaderSaver) Saver() (io.WriteCloser, error)

Saver provides an io.WriteCloser for writing a save file.

func (*BasicLoaderSaver) SaverFunc

func (ls *BasicLoaderSaver) SaverFunc() Saver

SaverFunc returns the Saver function used.

type Loader

type Loader func() (io.ReadCloser, error)

Loader is a function that returns a reader for a save file or database we want to safely read from.

type LoaderSaver

type LoaderSaver interface {
	Loader() (io.ReadCloser, error)
	Saver() (io.WriteCloser, error)
	LoaderFunc() Loader
	SaverFunc() Saver
}

LoaderSaver is the interface that pairs a Loader with a Saver.

type Saver

type Saver func() (io.WriteCloser, error)

Saver is a function that returns a writer to a save file or database we want to safely write to.

type TestingLoaderSaver

type TestingLoaderSaver struct {
	BasicLoaderSaver
	Readers []*TestingReader
	Writers []*TestingWriter
}

func NewTestingLoaderSaver

func NewTestingLoaderSaver() *TestingLoaderSaver

type TestingReader

type TestingReader struct {
	*bytes.Reader
	Closed bool
}

func (*TestingReader) Close

func (t *TestingReader) Close() error

type TestingWriter

type TestingWriter struct {
	*bytes.Buffer
	Closed bool
}

func (*TestingWriter) Close

func (t *TestingWriter) Close() error

Jump to

Keyboard shortcuts

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