datapath

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package datapath is the file-like path people and agents type to name a place inside a database: `/lists/to-buy/items`. Odd segments are collections and even segments record ids. Ids are written and shown escaped the way record.EscapeID (dal-go/record) escapes them, so `a/b.txt` is `a%2Fb%2Etxt` everywhere: in input, output and the server's keys.

See spec/features/database-context-navigation (REQ:path-resolution) and decision 0008.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Printable

func Printable(s string) string

Printable is s safe to print in a terminal: every non-printable rune (control characters, including ESC and BEL) is shown as \uXXXX.

Types

type Kind

type Kind string

Kind is what a path names.

const (
	Root       Kind = "root"
	Collection Kind = "collection"
	Record     Kind = "record"
)

Path kinds.

type Path

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

Path is an absolute location as unescaped segments; the zero value is "/".

func FromKey

func FromKey(key string) (Path, error)

FromKey parses a server key ("lists/to-buy", escaped segments).

func Parse

func Parse(input string) (Path, error)

Parse is Resolve from the root.

func Resolve

func Resolve(base Path, input string) (Path, error)

Resolve applies input to base: a leading `/` is absolute, anything else is relative; `.` stays, `..` goes up one segment and never above `/`, and empty segments are ignored. A `%` that does not start one of the six record.EscapeID sequences is invalid_argument.

func (Path) Arg

func (p Path) Arg() string

Arg is Display as one shell argument, quoted when needed (POSIX quoting; PowerShell's on Windows), for commands people copy (paths.QuoteArg is the one quoting rule).

func (Path) Child

func (p Path) Child(segment string) Path

Child is p with one more (unescaped) segment.

func (Path) Display

func (p Path) Display() string

Display is String made safe to print (see Printable); paths built from names the server returned may hold characters input never allows.

func (Path) Key

func (p Path) Key() string

Key is p as the server's key path: escaped segments without the leading slash ("lists/to-buy"); "" for the root.

func (Path) Kind

func (p Path) Kind() Kind

Kind reports whether p is the root, a collection or a record.

func (Path) Name

func (p Path) Name() string

Name is the last segment unescaped, "" for the root.

func (Path) Parent

func (p Path) Parent() Path

Parent is p without its last segment; the root's parent is the root.

func (Path) Segments

func (p Path) Segments() []string

Segments returns the unescaped segments.

func (Path) String

func (p Path) String() string

String is p as people read and type it: absolute, ids escaped.

func (Path) URLKey

func (p Path) URLKey() string

URLKey is Key made safe for a URL path: every byte outside the unreserved set is percent-encoded, except the `%` of an EscapeID sequence, which the server unescapes per segment.

Jump to

Keyboard shortcuts

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