ud

package
v5.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: BSD-2-Clause, BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is the storage object for the higher level ud.Manager object. This storage implementation is written for client side.

func NewOrLoadStore

func NewOrLoadStore(kv *versioned.KV) (*Store, error)

NewOrLoadStore loads the Store object from the provided versioned.KV.

func (*Store) BackUpMissingFacts

func (s *Store) BackUpMissingFacts(username, email, phone fact.Fact) error

BackUpMissingFacts adds a registered fact to the Store object. It can take in both an email and a phone number. One or the other may be an empty string, however both is considered an error. It checks for each whether that fact type already exists in the structure. If a fact type already exists, an error is returned. ************************************************************************ NOTE: This is done since BackUpMissingFacts is exposed to the bindings layer. This prevents front end from using this as the method to store facts on their end, which is not its intended use case. It's intended use case is to store already registered facts, prior to the creation of this function. We handle storage of newly registered internally using Store.ConfirmFact. ************************************************************************ Any other fact.FactType is not accepted and returns an error and nothing is backed up. If you attempt to back up a fact type that has already been backed up, an error will be returned and nothing will be backed up. Otherwise, it adds the fact and returns whether the Store saved successfully.

func (*Store) ConfirmFact

func (s *Store) ConfirmFact(confirmationId string) error

ConfirmFact will delete the fact from the unconfirmed store and add it to the confirmed fact store. The Store will then be saved

func (*Store) DeleteFact

func (s *Store) DeleteFact(f fact.Fact) error

DeleteFact is our internal use function which will delete the registered fact from memory and storage. An error is returned if the fact does not exist in memory.

func (*Store) GetFacts

func (s *Store) GetFacts() []fact.Fact

GetFacts returns a list of fact.Fact objects that exist within the Store's confirmedFacts map.

func (*Store) GetStringifiedFacts

func (s *Store) GetStringifiedFacts() []string

GetStringifiedFacts returns a list of stringified facts from the Store's confirmedFacts map.

func (*Store) GetUsername

func (s *Store) GetUsername() (string, error)

GetUsername retrieves the username from the Store object. If it is not directly in the Store's username field, it is searched for in the map.

func (*Store) RestoreFromBackUp

func (s *Store) RestoreFromBackUp(backupData fact.FactList) error

RestoreFromBackUp initializes the confirmedFacts map with the backed up fact data. This will error if the store is already stateful.

func (*Store) StoreUnconfirmedFact

func (s *Store) StoreUnconfirmedFact(confirmationId string, f fact.Fact) error

StoreUnconfirmedFact stores a fact that has been added to UD but has not been confirmed by the user. It is keyed on the confirmation ID given by UD.

func (*Store) StoreUsername

func (s *Store) StoreUsername(f fact.Fact) error

StoreUsername forces the storage of a username fact.Fact into the Store's confirmedFacts map. The passed in fact.Fact must be of type fact.Username or this will not store the username.

Jump to

Keyboard shortcuts

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