rules

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package rules is guard/1's rules/1: the modes and classes of the protocol's table, a service's areas, and the document a stack's tool prints for the plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allows

func Allows(m Mode, cases []string) string

Allows is what the mode allows, with the cases' patterns in place of {{cases}}.

Types

type Area

type Area struct {
	Name  string
	Paths []string
	Modes []string
	Grant []string
}

Area is a named set of paths. Nil Modes leaves the class table in charge, so a grant only adds; empty Modes closes the paths in every mode.

func Areas

func Areas(defaults []Area, marker []byte) ([]Area, error)

Areas are the defaults with the marker's agents.areas merged in: an area the marker names replaces the default of that name.

func (Area) MarshalJSON

func (a Area) MarshalJSON() ([]byte, error)

type Class

type Class struct {
	Name     string   `yaml:"name" json:"name"`
	What     string   `yaml:"what" json:"-"`
	Patterns []string `yaml:"patterns" json:"patterns"`
}

type Document

type Document struct {
	Specrig string  `json:"specrig"`
	Modes   []Mode  `json:"modes"`
	Classes []Class `json:"classes"`
	Areas   []Area  `json:"areas"`
}

func Of

func Of(layout Layout, areas []Area) (Document, error)

Of is rules/1 for a stack's layout and a service's areas.

type Layout

type Layout map[string][]string

Layout is the patterns a stack fills the classes with, by class.

type Mode

type Mode struct {
	Name     string   `yaml:"name" json:"name"`
	Opens    []string `yaml:"opens" json:"opens"`
	Includes []string `yaml:"includes" json:"includes,omitempty"`
	Offered  *bool    `yaml:"offered" json:"offered,omitempty"`
	Allows   string   `yaml:"allows" json:"allows"`
	Brief    string   `yaml:"brief" json:"brief"`
}

func Lookup

func Lookup(name string) (Mode, error)

func Modes

func Modes() []Mode

Modes are the table's, in its order.

Jump to

Keyboard shortcuts

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