mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 17:14:44 +01:00
e43b5ce5e5
This is possible now that we no longer support go1.12 and brings rclone into line with standard practices in the Go world. This also removes errors.New and errors.Errorf from lib/errors and prefers the stdlib errors package over lib/errors.
35 lines
700 B
Go
35 lines
700 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// package errors
|
|
var (
|
|
ErrEmpty = errors.New("database empty")
|
|
ErrInactive = errors.New("database stopped")
|
|
ErrUnsupported = errors.New("unsupported on this OS")
|
|
)
|
|
|
|
// Op represents a database operation
|
|
type Op interface {
|
|
Do(context.Context, Bucket) error
|
|
}
|
|
|
|
// Bucket decouples bbolt.Bucket from key-val operations
|
|
type Bucket interface {
|
|
Get([]byte) []byte
|
|
Put([]byte, []byte) error
|
|
Delete([]byte) error
|
|
ForEach(func(bkey, data []byte) error) error
|
|
Cursor() Cursor
|
|
}
|
|
|
|
// Cursor decouples bbolt.Cursor from key-val operations
|
|
type Cursor interface {
|
|
First() ([]byte, []byte)
|
|
Next() ([]byte, []byte)
|
|
Seek([]byte) ([]byte, []byte)
|
|
}
|