Documentation ¶
Overview ¶
Package io implements convenience objects for working with the ipfs unixfs data format.
Index ¶
- Variables
- func ResolveUnixfsOnce(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error)deprecated
- type BasicDirectorydeprecated
- func (d *BasicDirectory) AddChild(ctx context.Context, name string, node ipld.Node) error
- func (d *BasicDirectory) EnumLinksAsync(ctx context.Context) <-chan format.LinkResult
- func (d *BasicDirectory) Find(ctx context.Context, name string) (ipld.Node, error)
- func (d *BasicDirectory) ForEachLink(_ context.Context, f func(*ipld.Link) error) error
- func (d *BasicDirectory) GetCidBuilder() cid.Builder
- func (d *BasicDirectory) GetNode() (ipld.Node, error)
- func (d *BasicDirectory) Links(ctx context.Context) ([]*ipld.Link, error)
- func (d *BasicDirectory) RemoveChild(ctx context.Context, name string) error
- func (d *BasicDirectory) SetCidBuilder(builder cid.Builder)
- type DagReaderdeprecated
- type Directorydeprecated
- type DynamicDirectorydeprecated
- type HAMTDirectorydeprecated
- func (d *HAMTDirectory) AddChild(ctx context.Context, name string, nd ipld.Node) error
- func (d *HAMTDirectory) EnumLinksAsync(ctx context.Context) <-chan format.LinkResult
- func (d *HAMTDirectory) Find(ctx context.Context, name string) (ipld.Node, error)
- func (d *HAMTDirectory) ForEachLink(ctx context.Context, f func(*ipld.Link) error) error
- func (d *HAMTDirectory) GetCidBuilder() cid.Builder
- func (d *HAMTDirectory) GetNode() (ipld.Node, error)
- func (d *HAMTDirectory) Links(ctx context.Context) ([]*ipld.Link, error)
- func (d *HAMTDirectory) RemoveChild(ctx context.Context, name string) error
- func (d *HAMTDirectory) SetCidBuilder(builder cid.Builder)
- type ReadSeekCloserdeprecated
Constants ¶
This section is empty.
Variables ¶
var ( // Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrIsDir ErrIsDir = errors.New("this dag node is a directory") // Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrCantReadSymlinks ErrCantReadSymlinks = errors.New("cannot currently read symlinks") // Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrUnkownNodeType ErrUnkownNodeType = errors.New("unknown node type") // Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrSeekNotSupported ErrSeekNotSupported = errors.New("file does not support seeking") )
Common errors
var DefaultShardWidth = 256
DefaultShardWidth is the default value used for hamt sharding width. Needs to be a power of two (shard entry size) and multiple of 8 (bitfield size).
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.DefaultShardWidth
var ErrNotADir = fmt.Errorf("merkledag node was not a directory or shard")
ErrNotADir implies that the given node was not a unixfs directory
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ErrNotADir
var HAMTShardingSize = int(256 * units.KiB)
HAMTShardingSize is a global option that allows switching to a HAMTDirectory when the BasicDirectory grows above the size (in bytes) signalled by this flag. The default size of 0 disables the option. The size is not the *exact* block size of the encoded BasicDirectory but just the estimated size based byte length of links name and CID (BasicDirectory's ProtoNode doesn't use the Data field so this estimate is pretty accurate).
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.HAMTShardingSize
Functions ¶
func ResolveUnixfsOnce
deprecated
func ResolveUnixfsOnce(ctx context.Context, ds ipld.NodeGetter, nd ipld.Node, names []string) (*ipld.Link, []string, error)
ResolveUnixfsOnce resolves a single hop of a path through a graph in a unixfs context. This includes handling traversing sharded directories.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.ResolveUnixfsOnce
Types ¶
type BasicDirectory
deprecated
type BasicDirectory struct {
// contains filtered or unexported fields
}
BasicDirectory is the basic implementation of `Directory`. All the entries are stored in a single node.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.BasicDirectory
func (*BasicDirectory) AddChild ¶
AddChild implements the `Directory` interface. It adds (or replaces) a link to the given `node` under `name`.
func (*BasicDirectory) EnumLinksAsync ¶
func (d *BasicDirectory) EnumLinksAsync(ctx context.Context) <-chan format.LinkResult
EnumLinksAsync returns a channel which will receive Links in the directory as they are enumerated, where order is not gauranteed
func (*BasicDirectory) ForEachLink ¶
ForEachLink implements the `Directory` interface.
func (*BasicDirectory) GetCidBuilder ¶
func (d *BasicDirectory) GetCidBuilder() cid.Builder
GetCidBuilder implements the `Directory` interface.
func (*BasicDirectory) GetNode ¶
func (d *BasicDirectory) GetNode() (ipld.Node, error)
GetNode implements the `Directory` interface.
func (*BasicDirectory) RemoveChild ¶
func (d *BasicDirectory) RemoveChild(ctx context.Context, name string) error
RemoveChild implements the `Directory` interface.
func (*BasicDirectory) SetCidBuilder ¶
func (d *BasicDirectory) SetCidBuilder(builder cid.Builder)
SetCidBuilder implements the `Directory` interface.
type DagReader
deprecated
type DagReader interface { ReadSeekCloser Size() uint64 CtxReadFull(context.Context, []byte) (int, error) }
A DagReader provides read-only read and seek acess to a unixfs file. Different implementations of readers are used for the different types of unixfs/protobuf-encoded nodes.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.DagReader
func NewDagReader
deprecated
NewDagReader creates a new reader object that reads the data represented by the given node, using the passed in DAGService for data retrieval.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.NewDagReader
type Directory
deprecated
type Directory interface { // SetCidBuilder sets the CID Builder of the root node. SetCidBuilder(cid.Builder) // AddChild adds a (name, key) pair to the root node. AddChild(context.Context, string, ipld.Node) error // ForEachLink applies the given function to Links in the directory. ForEachLink(context.Context, func(*ipld.Link) error) error // EnumLinksAsync returns a channel which will receive Links in the directory // as they are enumerated, where order is not gauranteed EnumLinksAsync(context.Context) <-chan format.LinkResult // Links returns the all the links in the directory node. Links(context.Context) ([]*ipld.Link, error) // Find returns the root node of the file named 'name' within this directory. // In the case of HAMT-directories, it will traverse the tree. // // Returns os.ErrNotExist if the child does not exist. Find(context.Context, string) (ipld.Node, error) // RemoveChild removes the child with the given name. // // Returns os.ErrNotExist if the child doesn't exist. RemoveChild(context.Context, string) error // GetNode returns the root of this directory. GetNode() (ipld.Node, error) // GetCidBuilder returns the CID Builder used. GetCidBuilder() cid.Builder }
Directory defines a UnixFS directory. It is used for creating, reading and editing directories. It allows to work with different directory schemes, like the basic or the HAMT implementation.
It just allows to perform explicit edits on a single directory, working with directory trees is out of its scope, they are managed by the MFS layer (which is the main consumer of this interface).
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.Directory
func NewDirectory
deprecated
func NewDirectory(dserv ipld.DAGService) Directory
NewDirectory returns a Directory implemented by DynamicDirectory containing a BasicDirectory that can be converted to a HAMTDirectory.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.NewDirectory
func NewDirectoryFromNode
deprecated
type DynamicDirectory
deprecated
added in
v0.3.0
type DynamicDirectory struct {
Directory
}
DynamicDirectory wraps a Directory interface and provides extra logic to switch from BasicDirectory to HAMTDirectory and backwards based on size.
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.DynamicDirectory
func (*DynamicDirectory) AddChild ¶ added in v0.3.0
AddChild implements the `Directory` interface. We check when adding new entries if we should switch to HAMTDirectory according to global option(s).
func (*DynamicDirectory) RemoveChild ¶ added in v0.3.0
func (d *DynamicDirectory) RemoveChild(ctx context.Context, name string) error
RemoveChild implements the `Directory` interface. Used in the case where we wrap a HAMTDirectory that might need to be downgraded to a BasicDirectory. The upgrade path is in AddChild.
type HAMTDirectory
deprecated
type HAMTDirectory struct {
// contains filtered or unexported fields
}
HAMTDirectory is the HAMT implementation of `Directory`. (See package `hamt` for more information.)
Deprecated: use github.com/ipfs/boxo/ipld/unixfs/io.HAMTDirectory
func (*HAMTDirectory) EnumLinksAsync ¶
func (d *HAMTDirectory) EnumLinksAsync(ctx context.Context) <-chan format.LinkResult
EnumLinksAsync returns a channel which will receive Links in the directory as they are enumerated, where order is not gauranteed
func (*HAMTDirectory) ForEachLink ¶
ForEachLink implements the `Directory` interface.
func (*HAMTDirectory) GetCidBuilder ¶
func (d *HAMTDirectory) GetCidBuilder() cid.Builder
GetCidBuilder implements the `Directory` interface.
func (*HAMTDirectory) GetNode ¶
func (d *HAMTDirectory) GetNode() (ipld.Node, error)
GetNode implements the `Directory` interface.
func (*HAMTDirectory) RemoveChild ¶
func (d *HAMTDirectory) RemoveChild(ctx context.Context, name string) error
RemoveChild implements the `Directory` interface.
func (*HAMTDirectory) SetCidBuilder ¶
func (d *HAMTDirectory) SetCidBuilder(builder cid.Builder)
SetCidBuilder implements the `Directory` interface.