libraryv1

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Local library v1

The library stores named exact RGB colors and frozen host Sequences. A Pattern has an ID, an optional title of up to 256 Unicode code points, and its normalized Sequence. Saving and reading enforce the title limit.

New, list and lookup operations leave a missing library directory absent. Saves create private directories and write a temporary 0600 record before atomic replacement. macOS and Linux directories use 0700. Windows uses inherited directory ACLs and replacement through MoveFileEx.

The dedicated root contains colors and patterns directories. Record filenames hex-encode the original name or ID so case-distinct Pattern IDs work on case-insensitive filesystems. Each record is bounded to 1 MiB. Limits are 256 colors and 128 Patterns.

Cooperating writers share the existing OS ownership lock while checking capacity and replacing a record. Lock acquisition waits up to two seconds. Readers open complete regular files with platform symlink guards. A saved Sequence is independent of later caller edits.

Documentation

Overview

Package libraryv1 persists the current local color and Sequence library.

Index

Constants

View Source
const (
	MaxRecordBytes = 1 << 20
	MaxColors      = 256
	MaxPatterns    = 128
	MaxTitleRunes  = 256
)

Variables

View Source
var (
	ErrNotFound = errors.New("library record not found")
	ErrInvalid  = errors.New("invalid library record")
	ErrCapacity = errors.New("library capacity exhausted")
)

Functions

This section is empty.

Types

type Color

type Color struct {
	Name  string `json:"name"`
	Color string `json:"color"`
}

type Pattern

type Pattern struct {
	ID       string            `json:"id"`
	Title    string            `json:"title,omitempty"`
	Sequence sequence.Sequence `json:"sequence"`
}

type Store

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

func New

func New(dir string) *Store

New remembers the directory without creating it. Relative paths are resolved now so a later working-directory change cannot redirect this Store.

func (*Store) GetPattern

func (s *Store) GetPattern(id string) (Pattern, error)

func (*Store) ListColors

func (s *Store) ListColors() ([]Color, error)

func (*Store) ListPatterns

func (s *Store) ListPatterns() ([]Pattern, error)

func (*Store) ResolveColor

func (s *Store) ResolveColor(name string) (string, error)

func (*Store) SaveColor

func (s *Store) SaveColor(name, color string) (Color, error)

func (*Store) SavePattern

func (s *Store) SavePattern(input Pattern) (Pattern, error)

Jump to

Keyboard shortcuts

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