named

package
v0.0.0-...-fcfcbe3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

named is a utility for dealing with named fiddles.

Index

Constants

This section is empty.

Variables

View Source
var (
	DuplicateNameErr = errors.New("Name already exists.")
)

Functions

This section is empty.

Types

type NameStore

type NameStore interface {
	GetHashFromName(name string) (string, error)
	WriteName(name, hash, user, status string) error
}

NameStore is an interface that store.Store conforms to that is just the methods that Named uses.

type Named

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

Named deals with creating and dereferencing named fiddles.

func New

func New(st NameStore) *Named

New creates a new Named.

func (*Named) Add

func (n *Named) Add(name, hash, user string, overwrite bool) error

Add a named fiddle.

name      - The name of the fidde, w/o the @ prefix.
hash      - The fiddle hash.
user      - The email of the user that created the name.
overwrite - True if the write should proceed if the name already exists.

func (*Named) DereferenceID

func (n *Named) DereferenceID(id string) (string, error)

Dereference converts the id to a fiddlehash, where id could be either a fiddle name or a fiddle hash. Fiddle names are presumed to be prefixed with "@".

Returns an error if the fiddle hash is not valid looking.

func (*Named) DereferenceImageID

func (n *Named) DereferenceImageID(id string) (string, store.Media, error)

DereferenceImageID converts the id of an image to the fiddle hash and the Media it represents, handling both original fiddle hashes and fiddle names as part of the image id. Fiddle names are presumed to be prefixed with "@".

I.e. it converts "cbb8dee39e9f1576cd97c2d504db8eee_gpu.png" to "cbb8dee39e9f1576cd97c2d504db8eee" and store.GPU. and, could also convert "@star_raster.png" to "cbb8dee39e9f1576cd97c2d504db8eee" and store.CPU.

Jump to

Keyboard shortcuts

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