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 // contains filtered or unexported fields }
TestingLoaderSaver provides an in-memory loader and saver for testing.
func NewTestingLoaderSaver ¶
func NewTestingLoaderSaver() *TestingLoaderSaver
NewTestingLoaderSaver returns a new, blank TestingLoaderSaver.
func (*TestingLoaderSaver) Buffers ¶ added in v0.1.0
func (t *TestingLoaderSaver) Buffers() []*bytes.Buffer
Buffers returns each buffer written by the saver in the order it occurred.
func (*TestingLoaderSaver) CurrentReader ¶ added in v0.1.1
func (t *TestingLoaderSaver) CurrentReader() int
CurrentReader returns the index of the current reader and can be used as the key into ReadersClosed to determine which was or was not closed.
func (*TestingLoaderSaver) CurrentWriter ¶ added in v0.1.1
func (t *TestingLoaderSaver) CurrentWriter() int
CurrentWriter returns the index of the current writer and can be used as the key into WritersClosed to determine which was or was not closed.
func (*TestingLoaderSaver) ReadersClosed ¶ added in v0.1.1
func (t *TestingLoaderSaver) ReadersClosed() []bool
ReadersClosed returns a slice of booleans indicating whether each reader created was closed.
func (*TestingLoaderSaver) WritersClosed ¶ added in v0.1.1
func (t *TestingLoaderSaver) WritersClosed() []bool
WritersClosed returns a slice of booleans indicating whether each writer created was closed.
type TestingReader ¶
type TestingReader struct { *bytes.Reader // the in-memory reader Closed bool // whether the reader has been closed }
TestingReader provides an in-memory reader for testing.
func (*TestingReader) Close ¶
func (t *TestingReader) Close() error
Close marks the reader as closed.
type TestingWriter ¶
type TestingWriter struct { *bytes.Buffer // the in-memory writer Closed bool // whether the writer has been closed // contains filtered or unexported fields }
TestingWriter provides an in-memory writer for testing.
func (*TestingWriter) Close ¶
func (t *TestingWriter) Close() error
Close marks the writer as closed.