common

package
v0.0.0-...-5233cc8 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Unlicense Imports: 12 Imported by: 0

README

common

The types here are meant to be used as abstract classes and be extended by the actual implementations of each of the defined types. They provide implementations of functions where the logic is implementation-agnostic and can be shared across all backends

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareUUIDs

func CompareUUIDs(me t.UUIDer, them t.UUIDer) (bool, error)

func FindPathToGroup

func FindPathToGroup(source t.Group, target t.Group) (rv []t.Group, err error)

func FormatTime

func FormatTime(t time.Time) (formatted string)

func GenerateFileHash

func GenerateFileHash(filename string) (hash string, err error)

Types

type Attachment

type Attachment struct {
	EntryValue
}

func (Attachment) FormattedValue

func (a Attachment) FormattedValue(full bool) string

func (Attachment) Output

func (a Attachment) Output(showProtected bool) string

type Backend

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

func InitBackend

func InitBackend(filename string) (*Backend, error)

func (Backend) Filename

func (b Backend) Filename() string

Accessor functions for private variables

func (Backend) Hash

func (b Backend) Hash() string

func (Backend) IsModified

func (b Backend) IsModified() (bool, error)

IsModified determines whether or not the underlying storage has been modified since the utility was opened, indicating that something will get stomped

type Database

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

func (*Database) Backend

func (d *Database) Backend() t.Backend

func (*Database) Backup

func (d *Database) Backup() error

Backup executes a backup, if the database exists, otherwise it will do nothing

func (*Database) BackupPath

func (d *Database) BackupPath() string

BackupPath returns the path to which a backup can be written or restored

func (*Database) Changed

func (d *Database) Changed() bool

func (*Database) CurrentLocation

func (d *Database) CurrentLocation() t.Group

CurrentLocation returns the group currently used as the user's shell location in the DB

func (*Database) Lock

func (d *Database) Lock() error

Lock generates a lockfile for the given database

func (*Database) Locked

func (d *Database) Locked() bool

Locked returns whether or not the lockfile exists

func (*Database) Path

func (d *Database) Path() (string, error)

Path will walk up the group hierarchy to determine the path to the current location

func (*Database) RemoveBackup

func (d *Database) RemoveBackup() error

RemoveBackup will delete the backup database

func (*Database) RestoreBackup

func (d *Database) RestoreBackup() error

RestoreBackup will restore a backup from the BackupPath() to the original file path. This will overwrite whatever's in the main location, handle with care

func (*Database) SavePath

func (d *Database) SavePath() string

SavePath is a shortcut for getting the backend's filename

func (*Database) Search

func (d *Database) Search(term *regexp.Regexp) (paths []string, err error)

Search looks through a database for an entry matching a given term

func (*Database) SetBackend

func (d *Database) SetBackend(backend *Backend)

SetBackend and Backend manage a cached hash representing the state of the backend

func (*Database) SetChanged

func (d *Database) SetChanged(changed bool)

func (*Database) SetCurrentLocation

func (d *Database) SetCurrentLocation(g t.Group)

func (*Database) SetDriver

func (d *Database) SetDriver(driver t.Database)

SetDriver sets pointer to the version of itself that can access child methods... FIXME this is a bit of a mind bender

func (*Database) SetSavePath

func (d *Database) SetSavePath(path string)

SetSavePath is a shortcut for setting the backend filename

func (*Database) Unlock

func (d *Database) Unlock() error

Unlock removes the lock file on the current savepath of the database

type Entry

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

func (*Entry) DB

func (e *Entry) DB() t.Database

func (*Entry) Output

func (e *Entry) Output(full bool) (val string)

func (*Entry) Parent

func (e *Entry) Parent() t.Group

func (*Entry) Path

func (e *Entry) Path() (path string, err error)

Path returns the fully qualified path to the entry, if there's no parent, only the name is returned

func (*Entry) Search

func (e *Entry) Search(term *regexp.Regexp) (paths []string, err error)

TODO test various fields to make sure they are searchable, consider adding searchability toggle

func (*Entry) SetDB

func (e *Entry) SetDB(db t.Database)

func (*Entry) SetDriver

func (e *Entry) SetDriver(entry t.Entry)

SetDriver sets pointer to the version of itself that can access child methods... FIXME this is a bit of a mind bender

func (*Entry) SetParent

func (e *Entry) SetParent(g t.Group) error

type EntryValue

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

func NewValue

func NewValue(value []byte, name string, searchable bool, protected bool, readOnly bool, valueType t.ValueType) EntryValue

NewValue initializes a value object

func (EntryValue) FormattedValue

func (v EntryValue) FormattedValue(full bool) string

FormattedValue returns the appropriately formatted value contents, with the `full` argument determining whether protected values should be returned in cleartext

func (EntryValue) Name

func (v EntryValue) Name() string

func (EntryValue) NameTitle

func (v EntryValue) NameTitle() string

func (EntryValue) Output

func (v EntryValue) Output(showProtected bool) string

func (EntryValue) Protected

func (v EntryValue) Protected() bool

func (EntryValue) ReadOnly

func (v EntryValue) ReadOnly() bool

func (EntryValue) Searchable

func (v EntryValue) Searchable() bool

func (EntryValue) Type

func (v EntryValue) Type() t.ValueType

func (EntryValue) Value

func (v EntryValue) Value() []byte

type Group

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

func (*Group) DB

func (g *Group) DB() t.Database

func (*Group) Path

func (g *Group) Path() (rv string, err error)

func (*Group) Search

func (g *Group) Search(term *regexp.Regexp) (paths []string, err error)

func (*Group) SetDB

func (g *Group) SetDB(d t.Database)

func (*Group) SetDriver

func (g *Group) SetDriver(gr t.Group)

SetDriver sets pointer to the version of itself that can access child methods... FIXME this is a bit of a mind bender

Jump to

Keyboard shortcuts

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