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) Copy(ctx context.Context, target *Node, path, newPath []byte, create bool, ...) error
- func (n *Node) Entry() []byte
- func (n *Node) HasPrefix(ctx context.Context, path []byte, l Loader) (bool, error)
- func (n *Node) Index() int64
- func (n *Node) IsEdgeType() bool
- func (n *Node) IsEmptyDirectory() 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) Move(ctx context.Context, target *Node, path, newPath []byte, create bool, ...) error
- func (n *Node) Prefix() [][]byte
- 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) WalkLevel(ctx context.Context, root []byte, l Loader, level uint, walker WalkLevelFunc) error
- func (n *Node) WalkNode(ctx context.Context, root []byte, l Loader, walkFn WalkNodeFunc) error
- type Saver
- type WalkFunc
- type WalkLevelFunc
- type WalkNodeFunc
Constants ¶
const ( File = iota Directory MaxLevel = math.MaxUint32 )
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") ErrInvalidFile = errors.New("invalid file") ErrMetadataTooLarge = errors.New("metadata too large") ErrForbiddenAction = errors.New("forbidden action") )
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 ¶
type Loader interface {
Load(ctx context.Context, reference []byte, index int64) (data []byte, err error)
}
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) IsEmptyDirectory ¶ added in v1.2.0
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
func (*Node) Walk ¶
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.
type WalkFunc ¶
WalkFunc is the type of the function called for each file or directory visited by Walk.