settings

package
v0.0.0-...-2ca223a Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: AGPL-3.0 Imports: 1 Imported by: 4

Documentation

Overview

Package settings provides a generic, simple key-value pair like interface for saving application settings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(b Settings, key string) ([]byte, error)

Bytes gets a []byte type value from the settings.

func String

func String(b Settings, key string) (string, error)

String gets a string-type value from the settings.

Types

type Identity

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

Identity implements an identity store that

func NewIdentity

func NewIdentity(s Settings, k string) *Identity

NewIdentity create a new identity store.

func (*Identity) Check

func (s *Identity) Check() (bool, error)

Check checks if a value is set already.

func (*Identity) Load

func (s *Identity) Load(v interface{}) error

Load loads a value.

func (*Identity) Save

func (s *Identity) Save(v interface{}) error

Save saves the value into the store.

type Settings

type Settings interface {
	// Get gets a setting. Returns errcode.NotFound error when the
	// key is missing.
	Get(key string, v interface{}) error

	// Set sets a setting.
	Set(key string, v interface{}) error

	// Has checks if a key exists. It does not have to read the key.
	Has(key string) (bool, error)
}

Settings is an interface for saving simple JSON object based settings.

type Table

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

Table is a pisces.KV based settings implementation.

func NewTable

func NewTable(b *pisces.Tables) *Table

NewTable creates a new settings table that is named as "settings".

func NewTableName

func NewTableName(b *pisces.Tables, name string) *Table

NewTableName creates a new settings table using the given table name.

func (*Table) Get

func (b *Table) Get(key string, v interface{}) error

Get gets a settings.

func (*Table) Has

func (b *Table) Has(key string) (bool, error)

Has checks if a setting exists.

func (*Table) Set

func (b *Table) Set(key string, v interface{}) error

Set sets the value of a settings key.

Jump to

Keyboard shortcuts

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