Documentation
¶
Overview ¶
Package store provides an abstract way to work with i/o
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUInt32Overflow is returned when an integer is too large to be represented ErrUInt32Overflow = errors.New("bytesInput: uint32 overflow") // ErrNegativeOffset tells that it was an attempt to get access with a negative offset ErrNegativeOffset = errors.New("bytesInput: negative offset") // ErrOutOfRange tells that it was an attemot to get access out of range ErrOutOfRange = errors.New("bytesInput: try to get access out of range") // ErrInvalidWhence tells that the whence has invalid value ErrInvalidWhence = errors.New("bytesInput: invalid whence") )
Functions ¶
This section is empty.
Types ¶
type Directory ¶
type Directory interface {
// CreateOutput creates a new writer in the given directory with the given name
CreateOutput(name string) (Output, error)
// OpenInput returns a reader for the given name
OpenInput(name string) (Input, error)
}
Directory is a flat list of files. Inspired by org.apache.lucene.store.Directory
func NewFSDirectory ¶
NewFSDirectory creates a new instance of FS Directory
func NewRAMDirectory ¶
func NewRAMDirectory() Directory
NewRAMDirectory returns a new instance of RAM Directory
type Input ¶
type Input interface {
io.Closer
io.ReadSeeker
io.ReaderAt
io.ByteReader
// Slice returns a slice of the given Input
Slice(off int64, n int64) (Input, error)
// ReadVUInt32 reads a variable-length encoded uint32 number
ReadVUInt32() (uint32, error)
// ReadUInt32 reads four bytes and returns uint32
ReadUInt32() (uint32, error)
// ReadUInt16 reads two bytes and returns uint16
ReadUInt16() (uint16, error)
}
Input is a wrap for methods Read and retrieving underlying data
func NewBytesInput ¶
NewBytesInput creates a new instance of byteInput
type Marshaler ¶
type Marshaler interface {
// Store encodes the receiver into a binary form and saves the result into the provided Output.
// Returns the number of written bytes or an error otherwise.
Store(out Output) (int, error)
}
Marshaler is the interface implemented by an object that can marshal itself into a binary form.
type Output ¶
type Output interface {
io.Closer
io.Writer
// WriteVUInt32 writes the given uint32 in the variable-length format
WriteVUInt32(v uint32) (int, error)
// WriteUInt32 writes the given uint32 in the binary format
WriteUInt32(v uint32) (int, error)
// WriteUInt16 writes the given uint16 number in the binary format
WriteUInt16(v uint16) (int, error)
// WriteByte writes the given byte
WriteByte(v byte) error
}
Output is a wrap for method Write
func NewBytesOutput ¶
NewBytesOutput creates a new instance of byteOutput
type SliceAccessible ¶
type SliceAccessible interface {
// Data returns the underlying content as byte slice
Data() []byte
}
SliceAccessible represents the entity with the ability to return underlying byte slice
type Unmarshaler ¶
type Unmarshaler interface {
// Load decodes the form generated by MarshalBinary from the given Input.
// Returns the number of read bytes or an error otherwise.
Load(in Input) (int, error)
}
Unmarshaler is the interface implemented by an object that can unmarshal a binary representation of itself