exampleformatters

package
v0.0.0-...-64dd8ac Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base64Formatter

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

Base64Formatter is a simple formatter that formats and deformats data between a plaintext format and base64 format. It's intended for demonstrating formattedstore functionality. It's not intended for production usage.

func NewBase64Formatter

func NewBase64Formatter(useDeterministicKeyFormatting bool) *Base64Formatter

NewBase64Formatter creates a new Base64Formatter. If useDeterministicKeyFormatting is set to true, then the formatted keys output by the Base64Formatter will simply be base64-encoded versions of the unformatted keys. If useDeterministicKeyFormatting is set to false, then the formatted keys will instead be base64-formatted random UUIDs, with no relation to the unformatted key. This can be used to simulate the method by which the EDV Encrypted Formatter generates its formatted keys by default, which works in a similar way. An in-memory map is used to map between the random formatted keys and unformatted keys.

func (*Base64Formatter) Deformat

func (b *Base64Formatter) Deformat(formattedKey string, formattedValue []byte,
	formattedTags ...spi.Tag) (string, []byte, []spi.Tag, error)

Deformat returns base64-decoded versions of formattedKey, formattedValue, and formattedTags.

func (*Base64Formatter) Format

func (b *Base64Formatter) Format(key string, value []byte, tags ...spi.Tag) (string, []byte, []spi.Tag,
	error)

Format returns base64-encoded versions of key, value, and tags.

func (*Base64Formatter) UsesDeterministicKeyFormatting

func (b *Base64Formatter) UsesDeterministicKeyFormatting() bool

UsesDeterministicKeyFormatting indicates whether this Base64Formatter has been set up to use deterministic key generation.

type NoOpFormatter

type NoOpFormatter struct{}

NoOpFormatter is a simple "formatter" intended for testing purposes that just passes whatever is passed into its methods back out again without modification.

func (*NoOpFormatter) Deformat

func (n *NoOpFormatter) Deformat(formattedKey string, formattedValue []byte, formattedTags ...spi.Tag) (string,
	[]byte, []spi.Tag, error)

Deformat takes formattedKey, formattedValue, and formattedTags and just directly passes them back out without modification.

func (*NoOpFormatter) Format

func (n *NoOpFormatter) Format(key string, value []byte,
	tags ...spi.Tag) (string, []byte, []spi.Tag, error)

Format takes key, value, and tags and just directly passes them back out without modification.

func (*NoOpFormatter) UsesDeterministicKeyFormatting

func (n *NoOpFormatter) UsesDeterministicKeyFormatting() bool

UsesDeterministicKeyFormatting always returns true since NoOpFormatter always does deterministic key formatting.

Jump to

Keyboard shortcuts

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