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, 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 signals too short input. ErrTooShort = errors.New("serialised input too short") // ErrInvalidInput signals invalid input to serialise. ErrInvalidInput = errors.New("input invalid") // ErrInvalidVersionHash signals unknown version of hash. ErrInvalidVersionHash = errors.New("invalid version hash") )
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 ¶
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, entry []byte, metadata map[string]string, ls LoadSaver) error
Add adds an entry to the path
func (*Node) IsEdgeType ¶
IsEdgeType returns true if the node forks into other nodes.
func (*Node) IsValueType ¶
IsValueType returns true if the node contains entry.
func (*Node) IsWithMetadataType ¶
IsWithMetadataType returns true if the node contains metadata.
func (*Node) IsWithPathSeparatorType ¶
IsWithPathSeparatorType returns true if the node path contains separator character.
func (*Node) LookupNode ¶
LookupNode finds the node for a path or returns error if not found
func (*Node) MarshalBinary ¶
MarshalBinary serialises the node
func (*Node) SetObfuscationKey ¶
func (*Node) UnmarshalBinary ¶
UnmarshalBinary deserialises a node