nodestyle

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind uint8
type Link interface {
	Prototype() LinkPrototype
}

type LinkContext

type LinkContext struct {
	LinkPath   Path
	LinkNode   Node // has the Link again, but also might have type info // always zero for writing new nodes, for obvi reasons. // dubious if this is needed; would rather make Link impls just also *be* Node.
	ParentNode Node
}

type LinkPrototype

type LinkPrototype interface {
}

type ListBuilder

type ListBuilder interface {
}

type MapBuilder

type MapBuilder interface {
}

type Node

type Node interface {
	Kind() Kind
	LookupByString(key string) (Node, error)
	LookupByNode(key Node) (Node, error)
	LookupByIndex(idx int) (Node, error)
	Length() int
	IsAbsent() bool
	IsNull() bool
	AsBool() (bool, error)
	AsInt() (int, error)
	AsFloat() (float64, error)
	AsString() (string, error)
	AsBytes() ([]byte, error)
	AsLink() (Link, error)

	Prototype() NodePrototype // note!  replaces `NodeBuilder` method!
}

type NodeBuilder

type NodeBuilder interface {
	BeginMap() (MapBuilder, error)   // note the "amend" options are gone -- now do it with feature detection on NodePrototypeSupportingAmend, instead!
	BeginList() (ListBuilder, error) // note the "amend" options are gone -- now do it with feature detection on NodePrototypeSupportingAmend, instead!
	CreateNull() (Node, error)
	CreateBool(bool) (Node, error)
	CreateInt(int) (Node, error)
	CreateFloat(float64) (Node, error)
	CreateString(string) (Node, error)
	CreateBytes([]byte) (Node, error)
	CreateLink(Link) (Node, error) // fixme this is dumb and all links should already be nodes; either that or their creation should hinge here, rather than elsewhere and be awkwardly doubled.

	Prototype() NodePrototype // it's unlikely this will often be needed, i think, but it's here nonetheless.  (maybe generic transform will find this easier to use than the one on the node?  i think both should end up in reach on the stack, but not sure.)
}

all the error methods here are still a serious question. i don't really like them. you can 'must' them away, but... squick?

... we should make a muster that stores them somewhere rather than panics.  or takes a type parameter for its panic, or `func(error) boxedError`.  or something.

type NodePrototype

type NodePrototype interface {
	NewBuilder() NodeBuilder // allocs!  (probably.  sometimes the alloc is still later.)
}

Prototype is the information that lets you make more of them, and do some basic behavioral inspection; Type is the information that lets you understand how a group of nodes is related in a schema and rules it will follow.

type NodePrototypeSupportingAmend

type NodePrototypeSupportingAmend interface {
	AmendingBuilder(base Node) NodeBuilder
}

type Path

type Path string

type StorageCommitter

type StorageCommitter func(Link) error

type StorageLoader

type StorageLoader func(ctx context.Context, lnk Link, lnkCtx LinkContext) (io.Reader, error) // just handles the concept of bytes -- might have an internal `(Link)->(filepath.Path)` func, but `Link` is otherwise opaque to it.

type StorageWriter

type StorageWriter func(ctx context.Context, lnkCtx LinkContext) (io.Writer, StorageCommitter, error)

Jump to

Keyboard shortcuts

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