Documentation ¶
Index ¶
- Constants
- Variables
- func Check(hf HashFunc, id ID, data []byte) error
- func Copy(ctx context.Context, dst Poster, src Getter, id ID) error
- func CopyAll(ctx context.Context, dst Poster, src GetLister) error
- func CopyAllBasic(ctx context.Context, dst Poster, src GetLister) error
- func DeleteAll(ctx context.Context, s Store) error
- func ForEach(ctx context.Context, s Lister, span Span, fn func(ID) error) error
- func GetBytes(ctx context.Context, s Getter, id ID) ([]byte, error)
- func GetF(ctx context.Context, s Getter, id ID, fn func([]byte) error) error
- func IsNotFound(err error) bool
- func IsTooLarge(err error) bool
- type Adder
- type CopyAllFrom
- type Deleter
- type ErrNotFound
- type Exister
- type GetLister
- type GetPoster
- type Getter
- type HashFunc
- type ID
- func (a ID) Compare(b ID) int
- func (a ID) Equals(b ID) bool
- func (id ID) IsZero() bool
- func (id ID) MarshalBase64() ([]byte, error)
- func (id ID) MarshalJSON() ([]byte, error)
- func (id *ID) Scan(x interface{}) error
- func (id ID) String() string
- func (id ID) Successor() ID
- func (id *ID) UnmarshalBase64(data []byte) error
- func (id *ID) UnmarshalJSON(data []byte) error
- func (id ID) Value() (driver.Value, error)
- type Lister
- type MemStore
- func (s *MemStore) Delete(ctx context.Context, id ID) error
- func (s *MemStore) Exists(ctx context.Context, id ID) (bool, error)
- func (s *MemStore) Get(ctx context.Context, id ID, buf []byte) (int, error)
- func (s *MemStore) Hash(x []byte) ID
- func (s *MemStore) Len() (count int)
- func (s *MemStore) List(ctx context.Context, span Span, ids []ID) (n int, err error)
- func (s *MemStore) MaxSize() int
- func (s *MemStore) Post(ctx context.Context, data []byte) (ID, error)
- type PostExister
- type Poster
- type Set
- type Span
- type Store
- type Void
- func (s Void) Delete(ctx context.Context, id ID) error
- func (s Void) Exists(ctx context.Context, id ID) (bool, error)
- func (s Void) Get(ctx context.Context, id ID, buf []byte) (int, error)
- func (s Void) Hash(x []byte) ID
- func (s Void) List(ctx context.Context, span Span, ids []ID) (int, error)
- func (s Void) MaxSize() int
- func (s Void) Post(ctx context.Context, data []byte) (ID, error)
Constants ¶
View Source
const ( IDSize = 32 // Base64Alphabet is used when encoding IDs as base64 strings. // It is a URL and filepath safe encoding, which maintains ordering. Base64Alphabet = "-0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "_" + "abcdefghijklmnopqrstuvwxyz" )
View Source
const DefaultMaxSize = 1 << 20
Variables ¶
View Source
var ( ErrTooLarge = errors.New("data is too large for store") ErrBadData = errors.New("data does not match ID") )
Functions ¶
func IsNotFound ¶
func IsTooLarge ¶
Types ¶
type Adder ¶
type Adder interface { // Add adds data to the store by ID. // It will return ErrNotFound if the data cannot be added. Add(ctx context.Context, id ID) error }
Adder defines the Add method
type CopyAllFrom ¶
type Deleter ¶
type Deleter interface { // Delete removes the data identified by id from the store Delete(ctx context.Context, id ID) error }
Deleter defines the Delete method
type ErrNotFound ¶
type ErrNotFound = state.ErrNotFound[ID]
type Exister ¶
type Exister interface { // Exists returns true, nil if the ID exists, and false, nil if it does not. // The boolean should not be interpretted if err != nil Exists(ctx context.Context, id ID) (bool, error) }
Exister defines the Exists method
type Getter ¶
type Getter interface { // Get copies data identified by id into buf. // If not all the data can be copied, it returns io.ErrShortBuffer // Otherwise n will be the number of bytes copied into buf. Get(ctx context.Context, id ID, buf []byte) (int, error) Hash(x []byte) ID MaxSize() int }
Getter defines the Get method
type ID ¶
ID identifies a particular piece of data
func BeginFromSpan ¶
BeginFromSpan returns the ID which begins the span. It will be lteq every other ID in the Span.
func DefaultHash ¶
func EndFromSpan ¶
EndFromSpan returns the cadata.ID which is greater than ever ID in the span, and true. Or it returns the zero ID and false if no such ID exists.
func IDFromBytes ¶
func (ID) MarshalBase64 ¶
MarshalBase64 encodes ID using Base64Alphabet
func (ID) MarshalJSON ¶
func (*ID) UnmarshalBase64 ¶
UnmarshalBase64 decodes data into the ID using Base64Alphabet
func (*ID) UnmarshalJSON ¶
type Lister ¶
type Lister interface { // List reads IDs from the store, in asceding order into ids. // All the ids will be >= gteq, if it is not nil. // All the ids will be < lt if it is not nil. List(ctx context.Context, span Span, ids []ID) (int, error) }
Lister defines the List method
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
type PostExister ¶
type Poster ¶
type Poster interface { // Post will store data, and return an ID that can be used to retrieve it later Post(ctx context.Context, data []byte) (ID, error) MaxSize() int Hash(x []byte) ID }
Poster defines the Post method
Click to show internal directories.
Click to hide internal directories.