Documentation ¶
Overview ¶
Package codec provides support for serializing and deserializing file-hash information using channels.
Channel-based operation allows to stream file information, which becomes relevant when millions of files are supposed to be handled without any delay or noticeable memory overhead.
Index ¶
Constants ¶
const ( GobName = "gob" GobExtension = "gobz" Version = 1 )
const ( MHLName = "mhl" MHLExtension = "mhl" MHLVersion = "1.0" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Codec ¶
type Codec interface { // Write the file-info structures received from in channel to the given writer. // When the channel is closed, the read-operation naturally finishes. // The codec must protect the written data against modification, usually by hashing the contained information Serialize(in <-chan api.FileInfo, writer io.Writer) error // Stream a FileInfo obtained from the given reader. // An error must be returned if the data read could not be verified. // You must pass each read fileinfo structure to the given predicate - it might modify it before // sending it down the channel. It returns false in case you should stop reading and return without error // Check the done-channel and cancel the operation // This function doesn't close the stream // The only errors returned must of type DecodeError Deserialize(reader io.Reader, out chan<- api.FileInfo, predicate func(*api.FileInfo) bool) error // Extension returns the file extension of the codec, without the '.' prefix Extension() string }
Represents a codec's standard capabilities. A codec is a specialized implementation able to read and write indices of file hash information NOTE: Even though it would be more idiomatic to have two interfaces for read and write respectively, we just don't need it here
type DecodeError ¶ added in v1.0.0
type DecodeError struct {
Msg string
}
func (*DecodeError) Error ¶ added in v1.0.0
func (d *DecodeError) Error() string
type Gob ¶
type Gob struct { }
Reads and writes a file structured like so - version - numEntries - gobValue... - sha1 (hash of all hashes in prior map)
func (*Gob) Deserialize ¶
type MHL ¶ added in v1.0.0
type MHL struct { }
Empty type to implement the codec interface
func (*MHL) Deserialize ¶ added in v1.0.0
type SignatureMismatchError ¶ added in v1.0.0
type SignatureMismatchError struct {
DecodeError
}
func (*SignatureMismatchError) Error ¶ added in v1.0.0
func (s *SignatureMismatchError) Error() string