mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-22 09:28:06 +08:00
coreapi: functional options for DagAPI
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
@ -7,6 +7,8 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
|
||||
|
||||
ipld "gx/ipfs/QmNwUEK7QbwSqyKBu3mMtToo8SUc6wQJ7gdZq4gGGJqfnf/go-ipld-format"
|
||||
cid "gx/ipfs/QmeSrf6pzut73u6zLQkRFQ3ygt3k6XFT2kjdYP8Tnkwwyg/go-cid"
|
||||
)
|
||||
@ -60,14 +62,31 @@ type UnixfsAPI interface {
|
||||
type DagAPI interface {
|
||||
// Put inserts data using specified format and input encoding.
|
||||
// If format is not specified (nil), default dag-cbor/sha256 is used
|
||||
Put(ctx context.Context, src io.Reader, inputEnc string, format *cid.Prefix) ([]Node, error) //TODO: make format optional
|
||||
Put(ctx context.Context, src io.Reader, opts ...options.DagPutOption) ([]Node, error)
|
||||
|
||||
// WithInputEnc is an option for Put which specifies the input encoding of the
|
||||
// data. Default is "json", most formats/codecs support "raw"
|
||||
WithInputEnc(enc string) options.DagPutOption
|
||||
|
||||
// WithCodec is an option for Put which specifies the multicodec to use to
|
||||
// serialize the object. Default is cid.DagCBOR (0x71)
|
||||
WithCodec(codec uint64) options.DagPutOption
|
||||
|
||||
// WithHash is an option for Put which specifies the multihash settings to use
|
||||
// when hashing the object. Default is based on the codec used
|
||||
// (mh.SHA2_256 (0x12) for DagCBOR). If mhLen is set to -1, default length for
|
||||
// the hash will be used
|
||||
WithHash(mhType uint64, mhLen int) options.DagPutOption
|
||||
|
||||
// Get attempts to resolve and get the node specified by the path
|
||||
Get(ctx context.Context, path Path) (Node, error)
|
||||
|
||||
// Tree returns list of paths within a node specified by the path.
|
||||
// To get all paths in a tree, set depth to -1
|
||||
Tree(ctx context.Context, path Path, depth int) ([]Path, error)
|
||||
Tree(ctx context.Context, path Path, opts ...options.DagTreeOption) ([]Path, error)
|
||||
|
||||
// WithDepth is an option for Tree which specifies maximum depth of the
|
||||
// returned tree. Default is -1 (no depth limit)
|
||||
WithDepth(depth int) options.DagTreeOption
|
||||
}
|
||||
|
||||
// type ObjectAPI interface {
|
||||
|
Reference in New Issue
Block a user