command

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDisallowsTrailingSlash = fmt.Errorf("a command must not include a trailing slash")

ErrDisallowsTrailingSlash is returned when parsing a string that ends with a trailing slash character.

View Source
var ErrRequiresLeadingSlash = fmt.Errorf("a command requires a leading slash character")

ErrRequiresLeadingSlash is returned when a parsing a string that doesn't start with a leading slash character.

View Source
var ErrRequiresLowercase = fmt.Errorf("UCAN path segments must must not contain upper-case characters")

ErrRequiresLowercase is returned if a Command contains, or would contain, uppercase unicode characters.

Functions

func IsValid

func IsValid(s string) bool

IsValid returns true if the provided string is a valid UCAN command.

Types

type Command

type Command string

Command is a concrete messages (a "verb") that MUST be unambiguously interpretable by the Subject of a UCAN.

A Command is composed of a leading slash which is optionally followed by one or more slash-separated Segments of lowercase characters.

func MustParse

func MustParse(s string) Command

MustParse is the same as Parse, but panic() if the parsing fail.

func New

func New(segments ...string) Command

New creates a validated command from the provided list of segment strings. An error is returned if an invalid Command would be formed

func Parse

func Parse(s string) (Command, error)

Parse verifies that the provided string contains the required segment structure and, if valid, returns the resulting Command.

func Top

func Top() Command

Top is the most powerful capability.

This function returns a Command that is a wildcard and therefore represents the most powerful ability. As such, it should be handled with care and used sparingly.

func (Command) Covers

func (c Command) Covers(other Command) bool

Covers returns true if the command is identical or a parent of the given other command.

func (Command) Join

func (c Command) Join(segments ...string) Command

Join appends segments to the end of this command using the required segment separator.

func (Command) Segments

func (c Command) Segments() []string

Segments returns the ordered segments that comprise the Command as a slice of strings.

func (Command) String

func (c Command) String() string

String returns the composed representation the command. This is also the required wire representation (before IPLD encoding occurs.)

Jump to

Keyboard shortcuts

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