Documentation ¶
Overview ¶
Package sio implements a record-oriented persistency mechanism.
Index ¶
- Variables
- type Block
- type Codec
- type Decoder
- type Encoder
- type Linker
- type Marshaler
- type Operation
- type Reader
- type Record
- func (rec *Record) Compress() bool
- func (rec *Record) Connect(name string, ptr interface{}) error
- func (rec *Record) Disconnect()
- func (rec *Record) Name() string
- func (rec *Record) Options() uint32
- func (rec *Record) SetCompress(compress bool)
- func (rec *Record) SetUnpack(unpack bool)
- func (rec *Record) Unpack() bool
- type Stream
- func (stream *Stream) Close() error
- func (stream *Stream) CurPos() int64
- func (stream *Stream) DelRecord(n string)
- func (stream *Stream) Fd() uintptr
- func (stream *Stream) FileName() string
- func (stream *Stream) HasRecord(n string) bool
- func (stream *Stream) Mode() (os.FileMode, error)
- func (stream *Stream) Name() string
- func (stream *Stream) ReadRecord() (*Record, error)
- func (stream *Stream) Record(name string) *Record
- func (stream *Stream) Records() []*Record
- func (stream *Stream) Seek(offset int64, whence int) (int64, error)
- func (stream *Stream) SetCompressionLevel(lvl int)
- func (stream *Stream) Stat() (os.FileInfo, error)
- func (stream *Stream) Sync() error
- func (stream *Stream) WriteRecord(record *Record) error
- type Unmarshaler
- type Versioner
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( ErrStreamNoRecMarker = errors.New("sio: no record marker found") ErrRecordNoBlockMarker = errors.New("sio: no block marker found") ErrBlockConnected = errors.New("sio: block already connected") // ErrBlockShortRead means that the deserialization of a SIO block // read too few bytes with regard to what was written out in the // Block header length. ErrBlockShortRead = errors.New("sio: read too few bytes") )
Functions ¶
This section is empty.
Types ¶
type Block ¶
Block is the interface implemented by an object that can be stored to (and loaded from) an SIO stream.
type Codec ¶
type Codec interface { Marshaler Unmarshaler }
Code is the interface implemented by an object that can unmarshal and marshal itself from and to a binary, sio-compatible, form.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes SIO streams. Decoder provides a nice API to deal with errors that may occur during decoding.
func NewDecoder ¶
NewDecoder creates a new Decoder reading from the provided sio.Reader.
func (*Decoder) Decode ¶
func (dec *Decoder) Decode(ptr interface{})
Decode reads the next value from the input sio stream and stores it in the data, an empty interface value wrapping a pointer to a concrete value.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder encodes values into a SIO stream. Encoder provides a nice API to deal with errors that may occur during encoding.
func NewEncoder ¶
NewEncoder creates a new Encoder writing to the provided sio.Writer.
func (*Encoder) Encode ¶
func (enc *Encoder) Encode(data interface{})
Encode writes the next value to the output sio stream.
type Linker ¶
Linker is the interface implemented by an object that needs to recompute (internal) pointers, after the sio layer had performed pointer tagging/chasing relocation.
type Marshaler ¶
Marshaler is the interface implemented by an object that can marshal itself into a binary, sio-compatible, form.
type Reader ¶
type Reader interface { io.Reader Versioner Tag(ptr interface{}) error Pointer(ptr interface{}) error }
Reader is the interface that wraps the basic io.Reader interface and adds SIO pointer tagging capabilities.
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record manages blocks of data
func (*Record) Disconnect ¶
func (rec *Record) Disconnect()
Disconnect disconnects all blocks previously connected to this Record (for reading or writing.)
func (*Record) SetCompress ¶
SetCompress sets or resets the compression flag
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream manages operations of a single RIO stream.
func (*Stream) DelRecord ¶
DelRecord removes the Record with name n from this Stream. DelRecord is a no-op if such a Record was not known to the Stream.
func (*Stream) Fd ¶
Fd returns the integer Unix file descriptor referencing the underlying open file.
func (*Stream) HasRecord ¶
HasRecord returns whether a Record with name n has been added to this Stream
func (*Stream) ReadRecord ¶
ReadRecord reads the next record
func (*Stream) Record ¶
Record adds a Record to the list of records to read/write or returns the Record with that name.
func (*Stream) Seek ¶
Seek sets the offset for the next Read or Write on the stream to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.
func (*Stream) SetCompressionLevel ¶
SetCompressionLevel sets the (zlib) compression level
func (*Stream) Stat ¶
Stat returns the FileInfo structure describing underlying file. If there is an error, it will be of type *os.PathError.
func (*Stream) WriteRecord ¶
type Unmarshaler ¶
Unmarshaler is the interface implemented by an object that can unmarshal a binary, sio-compatible, representation of itself.