github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/lib/kv/types.go (about) 1 package kv 2 3 import ( 4 "context" 5 "errors" 6 ) 7 8 // package errors 9 var ( 10 ErrEmpty = errors.New("database empty") 11 ErrInactive = errors.New("database stopped") 12 ErrUnsupported = errors.New("unsupported on this OS") 13 ) 14 15 // Op represents a database operation 16 type Op interface { 17 Do(context.Context, Bucket) error 18 } 19 20 // Bucket decouples bbolt.Bucket from key-val operations 21 type Bucket interface { 22 Get([]byte) []byte 23 Put([]byte, []byte) error 24 Delete([]byte) error 25 ForEach(func(bkey, data []byte) error) error 26 Cursor() Cursor 27 } 28 29 // Cursor decouples bbolt.Cursor from key-val operations 30 type Cursor interface { 31 First() ([]byte, []byte) 32 Next() ([]byte, []byte) 33 Seek([]byte) ([]byte, []byte) 34 }