Documentation ¶
Overview ¶
Package cas implements a Content-Addressed Store.
Data stored in it will be cryptographically hashed into a Key, that can later be used to fetch the data. Storing the same data again will result in the same Key, and not take extra space.
Index ¶
Constants ¶
const KeySize = 64
Size of the CAS keys in bytes.
Variables ¶
var Empty = Key{}
The Empty key is special, it denotes no data stored (potentially after discarding trailing zeroes in the data). The empty key is all zero bytes.
var Invalid = Key{newInvalidKey()}
The Invalid key is special, it denotes input to NewKey that contained to use a reserved or private key. Or, respectively, just reserved for NewKeyPrivate.
These key byte values are never marshaled anywhere, so seeing them in input is always illegal.
Functions ¶
This section is empty.
Types ¶
type BadKeySizeError ¶
type BadKeySizeError struct {
Key []byte
}
BadKeySizeError is passed to panic if NewKey is called with input that is not KeySize long.
func (*BadKeySizeError) Error ¶
func (b *BadKeySizeError) Error() string
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
A Key that identifies data stored in the CAS. Keys are immutable.
func NewKey ¶
NewKey makes a new Key with the given byte contents. If the input happens to be a reserved byte sequence, the returned key will be Invalid.
This function is intended for use when unmarshaling keys from storage.
panics with BadKeySizeError if len(b) does not match KeySize
func NewKeyPrivate ¶
NewKeyPrivate is like NewKey, but allows byte sequences in the private range. The private data can be extracted with the method Private.
panics with BadKeySize if len(b) does not match KeySize
func NewKeyPrivateNum ¶
NewKeyPrivateNum makes a new Key in the private range, with the given number encoded in it. The number can be extracted from the key with the method Private.
func (*Key) IsPrivate ¶
IsPrivate returns true if the key is private. Private keys can be used to store 64 bits of data in them, but cannot be stored persistently. See Private, NewKeyPrivate, NewKeyPrivateNum.
func (*Key) IsReserved ¶
IsReserved returns true if the key is reserved. Caller should never use reserved keys.
func (*Key) IsSpecial ¶
IsSpecial returns true if the key is special. Special keys are further categorized into:
- Empty key: test with k == Empty
- Private keys: test with k.IsPrivate() or num, ok = k.Private()
- Reserved keys: test with k.IsReserved(); includes the Invalid key
func (*Key) MarshalBinary ¶
func (*Key) Private ¶
Private extracts the private data from a Key in the private range. The return value ok is false if the Key was not a private key.
func (*Key) UnmarshalBinary ¶
type NotFoundError ¶
NotFoundError is the type of error returned by a CAS when it cannot find the requested key.
func (NotFoundError) Error ¶
func (n NotFoundError) Error() string
Directories ¶
Path | Synopsis |
---|---|
Package chunks implements low-level storage for chunks of data.
|
Package chunks implements low-level storage for chunks of data. |
chunkutil
Package chunkutil contains helper functions only needed by chunks.Store implementations.
|
Package chunkutil contains helper functions only needed by chunks.Store implementations. |
mock
Package mock contains chunks.Store implementation for testing.
|
Package mock contains chunks.Store implementation for testing. |
Package flagx contains a helper type for parsing CAS keys from command line arguments.
|
Package flagx contains a helper type for parsing CAS keys from command line arguments. |
Package wire is a generated protocol buffer package.
|
Package wire is a generated protocol buffer package. |