This page permanently redirects to gemini://code.pfad.fr/gohmekit/storage/.

storage package - code.pfad.fr/gohmekit

import "code.pfad.fr/gohmekit/storage"

Functions

func NewMemDatabase

func NewMemDatabase() pairing.Database

NewMemDatabase is an in-memory database for testing (not thread-safe!)

Types

type JSONFile

type JSONFile struct {
	Path string
	pairing.AccessoryDevice
	// contains filtered or unexported fields
}

JSONFile implements pairing.Database and pairing.AccessoryDevice, storing their settings in a JSON file.

func NewJSONFile

func NewJSONFile(path string, options ...Option) (*JSONFile, error)

NewJSONFile will use (and create if missing) a JSON file to act as a storage. It will use the given options, only if the concerned parameters are not already set. It will generate random pin and private key if let unspecified.

func (*JSONFile) AddLongTermPublicKey

func (j *JSONFile) AddLongTermPublicKey(c pairing.Controller) error

AddLongTermPublicKey is defined by the pairing.Database interface.

func (*JSONFile) DiscoveryService

func (j *JSONFile) DiscoveryService(serviceName string, port int, category discovery.Category) discovery.Service

DiscoveryService returns a discovery service, ready to be announced.

func (*JSONFile) GetLongTermPublicKey

func (j *JSONFile) GetLongTermPublicKey(id []byte) ([]byte, error)

GetLongTermPublicKey is defined by the pairing.Database interface.

func (*JSONFile) IsPaired

func (j *JSONFile) IsPaired() bool

IsPaired is defined by the pairing.Database interface.

func (*JSONFile) IsPairedWatcher

func (j *JSONFile) IsPairedWatcher(cb func(bool)) bool

IsPairedWatcher will trigger the callback on pairing change. It will overwrite any existing callback.

func (*JSONFile) ListLongTermPublicKey

func (j *JSONFile) ListLongTermPublicKey() ([]pairing.Controller, error)

ListLongTermPublicKey is defined by the pairing.Database interface.

func (*JSONFile) RemoveLongTermPublicKey

func (j *JSONFile) RemoveLongTermPublicKey(id []byte) error

RemoveLongTermPublicKey is defined by the pairing.Database interface.

func (*JSONFile) VersionWatcher

func (j *JSONFile) VersionWatcher(_ func(uint16)) uint16

VersionWatcher will never trigger the callback, since the version is changed on every restart.

type Option

type Option func(*jsonData)

Option is to set some default values on first run.

func WithEd25519PrivateKey

func WithEd25519PrivateKey(key []byte) Option

WithEd25519PrivateKey will set the private key if it wasn't previously set.

func WithPairingID

func WithPairingID(id []byte) Option

WithPairingID will set the pairing ID if it wasn't previously set.

func WithPin

func WithPin(pin string) Option

WithPin will set the pin if it wasn't previously set.

Files

=> jsonfile.go | memory.go

Breadcrumb

=> code.pfad.fr/gohmekit

Proxy Information
Original URL
gemini://code.pfad.fr/gohmekit/storage
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
308.084616 milliseconds
Gemini-to-HTML Time
1.867817 milliseconds

This content has been proxied by September (3851b).