parse

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountList

type AccountList interface {
	// Load all accounts from storage
	Load() error

	// Save all accounts to storage
	Save() error

	// Get list of accounts
	GetAccs() ([]account.Account, error)

	// Set list of accounts
	SetAccs(to_set []account.Account) error

	// Returns a string detailing the source of the data, to go on the titlebar
	GetSource() (DataSource, string)

	// Returns a string containing the path of the file this is attached to.
	GetSourceFilePath() string

	// Prepopulate all fields with those of the given file.
	// Completely erases what was already there.
	PrepopulateFromFile(path string, isDefault bool) error

	// Whether is password protected: is used to trigger the password prompt
	//
	// Even the CsvEnc module can *not* have a password, so this isn't all that useless
	IsPasswordProtected() bool

	// Decrypt. This needs to be done (ideally immediately) before any of the meaningful operations (i.e. GetAccs, WriteAccs, etc).
	// If IsPasswordProtected() returns false, this should not error, as it is perpetually decrypted.
	//
	// Is idempotent: in that if already in decrypted state, should do nothing and not error.
	//
	// This should set a password flag in the struct containing the password in one form or another.
	// After any operation, this password flag is CLEARED by the Recrypt() method, such that multiple operations can't be chained and so that the password doesn't reside in memory for too long.
	Decrypt(password cryptor.PasswordHash) error

	// Clears whatever password flag is set.
	// Called by all meaningful operations anyway, so user need not worry, unless explicit Recryption is required (i.e. if Decrypted but no operation was executed).
	//
	// Therefore is idempotent, if is already encrypted, does nothing
	//
	// See Decrypt(string) for use.
	Recrypt()

	// Checks that state of the password flag.
	// If IsPasswordProtected() returns false, this should always return true, as it is prepetually decrypted.
	// See Decrypt(string) for use.
	IsDecrypted() bool

	// Creates a new file from scratch, populating fields anew
	PopulateNew() error
}

A list of Accounts as an interface. This does not store the accounts themselves, merely how to retrieve them from and place them back into some store. This allows us to abstract all the file reading code behind this interface.

This also does, as a by-product, some error-checking. Any problems flagged by Validate constitute *detection issues*, whereas anything by GetAccs constitutes *content errors*.

detection issues are NOT errors, and ought not be treated as such.

type DataSource

type DataSource uint

Where the data was obtained from

const (
	NamedSource DataSource = iota
	FileSource
)

type PureAccountList

type PureAccountList interface {
	AccountList

	// Detect whether the account list is of the correct format.
	//
	// NOTE: this may not necessarily mean that there are no errors in the format, only that basic header checks and filetype checks pass.
	// Therefore, does not return error: as an invalid filetype ought not be an error, only a signal to move to the next filetype.
	Detect() bool

	// obtain the default filename it's expecting. see detector for more info
	GetDefaultFilename() string
}

type WayAccountList

type WayAccountList interface {
	AccountList

	// An estimate of how long decryption/encryption is supposed to take.
	// This is how long key derivation takes plus a liberal estimate of the (de|en)cryption itself.
	// If this is surpassed (adding a few seconds breathing room), the prompt warns the user
	// If pure, returns 0
	CryptionTimeEstimate() time.Duration

	// Gets the ID assigned to it in the .way file.
	GetWayTypeId() format.FileTypeId

	// Sets whether the account list is password-protected.
	SetPasswordProtected(isPasswordProtected bool)
}

Directories

Path Synopsis
modules
pure/csv
This package decodes files in "pure" csv form, that is a csv file with no encryption, encoding or headers.
This package decodes files in "pure" csv form, that is a csv file with no encryption, encoding or headers.
way/csv
Way format of csv.
Way format of csv.

Jump to

Keyboard shortcuts

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