Documentation
¶
Overview ¶
package unixfs/io implements convenience objects for working with the ipfs unixfs data format.
Index ¶
- Variables
- func NewBufDagReader(b []byte) *bufDagReader
- func NewPBFileReader(ctx context.Context, n *mdag.ProtoNode, pb *ftpb.Data, serv mdag.DAGService) *pbDagReader
- func ResolveUnixfsOnce(ctx context.Context, ds dag.DAGService, nd node.Node, names []string) (*node.Link, []string, error)
- type DagReader
- type Directory
- func (d *Directory) AddChild(ctx context.Context, name string, nd node.Node) error
- func (d *Directory) Find(ctx context.Context, name string) (node.Node, error)
- func (d *Directory) ForEachLink(ctx context.Context, f func(*node.Link) error) error
- func (d *Directory) GetNode() (node.Node, error)
- func (d *Directory) GetPrefix() *cid.Prefix
- func (d *Directory) Links(ctx context.Context) ([]*node.Link, error)
- func (d *Directory) RemoveChild(ctx context.Context, name string) error
- func (d *Directory) SetPrefix(prefix *cid.Prefix)
- type ReadSeekCloser
Constants ¶
This section is empty.
Variables ¶
var DefaultShardWidth = 256
DefaultShardWidth is the default value used for hamt sharding width.
var ErrCantReadSymlinks = errors.New("cannot currently read symlinks")
var ErrIsDir = errors.New("this dag node is a directory")
var ErrNotADir = fmt.Errorf("merkledag node was not a directory or shard")
ErrNotADir implies that the given node was not a unixfs directory
var ShardSplitThreshold = 1000
ShardSplitThreshold specifies how large of an unsharded directory the Directory code will generate. Adding entries over this value will result in the node being restructured into a sharded object.
var UseHAMTSharding = false
UseHAMTSharding is a global flag that signifies whether or not to use the HAMT sharding scheme for directory creation
Functions ¶
func NewBufDagReader ¶ added in v0.4.5
func NewBufDagReader(b []byte) *bufDagReader
func NewPBFileReader ¶ added in v0.4.5
func NewPBFileReader(ctx context.Context, n *mdag.ProtoNode, pb *ftpb.Data, serv mdag.DAGService) *pbDagReader
func ResolveUnixfsOnce ¶ added in v0.4.5
func ResolveUnixfsOnce(ctx context.Context, ds dag.DAGService, nd node.Node, names []string) (*node.Link, []string, error)
ResolveUnixfsOnce resolves a single hop of a path through a graph in a unixfs context. This includes handling traversing sharded directories.
Types ¶
type DagReader ¶
type DagReader interface {
ReadSeekCloser
Size() uint64
CtxReadFull(context.Context, []byte) (int, error)
Offset() int64
}
func NewDagReader ¶
func NewDagReader(ctx context.Context, n node.Node, serv mdag.DAGService) (DagReader, error)
NewDagReader creates a new reader object that reads the data represented by the given node, using the passed in DAGService for data retreival
type Directory ¶ added in v0.4.8
type Directory struct {
// contains filtered or unexported fields
}
func NewDirectory ¶
func NewDirectory(dserv mdag.DAGService) *Directory
NewDirectory returns a Directory. It needs a DAGService to add the Children
func NewDirectoryFromNode ¶ added in v0.4.8
func NewDirectoryFromNode(dserv mdag.DAGService, nd node.Node) (*Directory, error)
func (*Directory) AddChild ¶ added in v0.4.8
func (d *Directory) AddChild(ctx context.Context, name string, nd node.Node) error
AddChild adds a (name, key)-pair to the root node.
func (*Directory) Find ¶ added in v0.4.8
func (d *Directory) Find(ctx context.Context, name string) (node.Node, error)
func (*Directory) ForEachLink ¶ added in v0.4.8
func (d *Directory) ForEachLink(ctx context.Context, f func(*node.Link) error) error
func (*Directory) GetNode ¶ added in v0.4.8
func (d *Directory) GetNode() (node.Node, error)
GetNode returns the root of this Directory
func (*Directory) GetPrefix ¶ added in v0.4.12
func (d *Directory) GetPrefix() *cid.Prefix
GetPrefix returns the CID Prefix used
func (*Directory) Links ¶ added in v0.4.8
func (d *Directory) Links(ctx context.Context) ([]*node.Link, error)
func (*Directory) RemoveChild ¶ added in v0.4.8
func (d *Directory) RemoveChild(ctx context.Context, name string) error
type ReadSeekCloser ¶
type ReadSeekCloser interface {
io.Reader
io.Seeker
io.Closer
io.WriterTo
}