Documentation ¶
Index ¶
- Constants
- Variables
- func SetObfuscationKeyFn(fn func([]byte) (int, error))
- type LoadSaver
- type Loader
- type Node
- func (n *Node) Add(ctx context.Context, path []byte, entry []byte, metadata map[string]string, ...) error
- func (n *Node) Entry() []byte
- func (n *Node) HasPrefix(ctx context.Context, path []byte, l Loader) (bool, error)
- func (n *Node) IsEdgeType() bool
- func (n *Node) IsValueType() bool
- func (n *Node) IsWithMetadataType() bool
- func (n *Node) IsWithPathSeparatorType() bool
- func (n *Node) Lookup(ctx context.Context, path []byte, l Loader) ([]byte, error)
- func (n *Node) LookupNode(ctx context.Context, path []byte, l Loader) (*Node, error)
- func (n *Node) MarshalBinary() (bytes []byte, err error)
- func (n *Node) Metadata() map[string]string
- func (n *Node) Reference() []byte
- func (n *Node) Remove(ctx context.Context, path []byte, ls LoadSaver) error
- func (n *Node) Save(ctx context.Context, s Saver) error
- func (n *Node) SetObfuscationKey(obfuscationKey []byte)
- func (n *Node) String() string
- func (n *Node) UnmarshalBinary(data []byte) error
- func (n *Node) Walk(ctx context.Context, root []byte, l Loader, walkFn WalkFunc) error
- func (n *Node) WalkNode(ctx context.Context, root []byte, l Loader, walkFn WalkNodeFunc) error
- type Saver
- type WalkFunc
- type WalkNodeFunc
Constants ¶
const (
PathSeparator = '/' // path separator
)
Variables ¶
var ( // ErrTooShort too short input ErrTooShort = errors.New("serialised input too short") // ErrInvalid input to seralise invalid ErrInvalid = errors.New("input invalid") // ErrForkIvalid shows embedded node on a fork has no reference ErrForkIvalid = errors.New("fork node without reference") )
var ( ErrNotFound = errors.New("not found") ErrEmptyPath = errors.New("empty path") ErrMetadataTooLarge = errors.New("metadata too large") )
Error used when lookup path does not match
var ( // ErrNoSaver saver interface not given ErrNoSaver = errors.New("Node is not persisted but no saver") // ErrNoLoader saver interface not given ErrNoLoader = errors.New("Node is reference but no loader") )
var (
ZeroObfuscationKey []byte
)
Functions ¶
func SetObfuscationKeyFn ¶ added in v0.3.3
SetObfuscationKeyFn allows configuring custom function for generating obfuscation key.
NOTE: This should only be used in tests.
Types ¶
type LoadSaver ¶
LoadSaver is a composite interface of Loader and Saver it is meant to be implemented as thin wrappers around persistent storage like Swarm
type Loader ¶
Loader defines a generic interface to retrieve nodes from a persistent storage for read only operations only
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a mantaray Node
func NewNodeRef ¶
NewNodeRef is the exported Node constructor used to represent manifests by reference
func (*Node) Add ¶
func (n *Node) Add(ctx context.Context, path []byte, entry []byte, metadata map[string]string, ls LoadSaver) error
Add adds an entry to the path
func (*Node) IsEdgeType ¶ added in v0.3.0
IsEdgeType returns true if the node forks into other nodes.
func (*Node) IsValueType ¶ added in v0.3.0
IsValueType returns true if the node contains entry.
func (*Node) IsWithMetadataType ¶ added in v0.3.0
IsWithMetadataType returns true if the node contains metadata.
func (*Node) IsWithPathSeparatorType ¶ added in v0.3.0
IsWithPathSeparatorType returns true if the node path contains separator character.
func (*Node) LookupNode ¶ added in v0.2.0
LookupNode finds the node for a path or returns error if not found
func (*Node) MarshalBinary ¶
MarshalBinary serialises the node
func (*Node) Reference ¶ added in v0.2.0
Reference returns the address of the mantaray node if saved.
func (*Node) SetObfuscationKey ¶ added in v0.2.0
func (*Node) UnmarshalBinary ¶
UnmarshalBinary deserialises a node
func (*Node) Walk ¶ added in v0.2.0
Walk walks the node tree structure rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn.