storage

package
v0.0.0-...-7c3daf4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented = errors.New("feature not implemented")
	ErrAlreadyClosed  = errors.New("storage is closed")
	ErrInvalidStorage = errors.New("invalid storage")
	ErrInvalidKey     = errors.New("invalid key provided")
	ErrNoSuchEntry    = errors.New("no such entry")
	ErrNoIndex        = errors.New("no index present")
)

Functions

func Decode

func Decode[T any](data []byte, target *T) error

func Encode

func Encode(data any) ([]byte, error)

func Harden

func Harden(gcm cipher.AEAD, input any) ([]byte, error)

func NewGCM

func NewGCM(key []byte) (cipher.AEAD, error)

func Soften

func Soften[T any](gcm cipher.AEAD, encrypted []byte, target *T) error

Types

type BoltStorage

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

func (BoltStorage) Close

func (b BoltStorage) Close() error

func (BoltStorage) Create

func (b BoltStorage) Create(name, initialText string) (Entry, Index, error)

func (BoltStorage) Delete

func (b BoltStorage) Delete(id uuid.UUID) (Index, error)

func (BoltStorage) Index

func (b BoltStorage) Index() (Index, error)

func (BoltStorage) MoveDown

func (b BoltStorage) MoveDown(id uuid.UUID) (Index, error)

func (BoltStorage) MoveUp

func (b BoltStorage) MoveUp(id uuid.UUID) (Index, error)

func (BoltStorage) Read

func (b BoltStorage) Read(id uuid.UUID) (Entry, error)

func (BoltStorage) Rename

func (b BoltStorage) Rename(id uuid.UUID, newName string) (Index, error)

func (BoltStorage) Update

func (b BoltStorage) Update(entry Entry) error

type Entry

type Entry struct {
	Id   uuid.UUID
	Text string
}

func (Entry) String

func (e Entry) String() string

type EntryMeta

type EntryMeta struct {
	Name string
	Id   uuid.UUID
}

type Index

type Index []EntryMeta

func (Index) String

func (idx Index) String() string

type Note

type Note struct {
	Title string
	Body  string
}

type Storage

type Storage interface {
	Close() error

	Index() (Index, error)
	Rename(id uuid.UUID, newName string) (Index, error)
	MoveUp(id uuid.UUID) (Index, error)
	MoveDown(id uuid.UUID) (Index, error)

	Create(name, initialText string) (Entry, Index, error)
	Read(id uuid.UUID) (Entry, error)
	Update(entry Entry) error
	Delete(id uuid.UUID) (Index, error)
}

func NewBoltStorage

func NewBoltStorage(filename string, keyText []byte) (Storage, error)

Jump to

Keyboard shortcuts

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