store

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteStore

func WriteStore(password []byte, store Store) ([]byte, error)

WriteStore writes a Store as raw data to be saved. WriteStore uses password encrypt the Store and returns the encrypted data, or an error if the Store could not be encoded to JSON or could not be encrypted.

func WriteStoreContext added in v0.3.3

func WriteStoreContext(ctx context.Context, password []byte, store Store) ([]byte, error)

WriteStoreContext performs WriteStore with a context.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store defines a key-value storage in scrt.

func NewStore

func NewStore() Store

NewStore initializes a new Store.

func NewStoreContext added in v0.3.3

func NewStoreContext(ctx context.Context) Store

NewStoreContext performs NewStore with a context.

func ReadStore

func ReadStore(password []byte, data []byte) (Store, error)

ReadStore reads a scrt Store from raw data. ReadStore uses password to decrypt data and returns the Store, or an error if Store data could not be decrypted of parsed. A json.Unmarshal error can mean either that the wrong password was supplied, or that the Store is corrupted.

func ReadStoreContext added in v0.3.3

func ReadStoreContext(ctx context.Context, password []byte, data []byte) (Store, error)

ReadStoreContext performs ReadStore with a context.

func (Store) Get

func (s Store) Get(key string) ([]byte, error)

Get returns the value associated to key in the Store, or an error if none is associated.

func (Store) GetContext added in v0.3.3

func (s Store) GetContext(ctx context.Context, key string) ([]byte, error)

GetContext performs Get with a context.

func (Store) Has

func (s Store) Has(key string) bool

Has returns true if a value is associated to key in the Store.

func (Store) HasContext added in v0.3.3

func (s Store) HasContext(ctx context.Context, key string) bool

HasContext performs Has with a context.

func (Store) List added in v0.2.0

func (s Store) List() []string

List returns all the keys is the Store.

func (Store) ListContext added in v0.3.3

func (s Store) ListContext(ctx context.Context) []string

ListContext performs List with a context.

func (Store) Set

func (s Store) Set(key string, val []byte) error

Set associates the value to key in the Store, or an error if val is invalid.

func (Store) SetContext added in v0.3.3

func (s Store) SetContext(ctx context.Context, key string, val []byte) error

SetContext performs Set with a context.

func (Store) Unset

func (s Store) Unset(key string)

Unset removes any value associated to key in the Store.

func (Store) UnsetContext added in v0.3.3

func (s Store) UnsetContext(ctx context.Context, key string)

UnsetContext performs Unset with a context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL