unixfs.go 1.37 KB
Newer Older
1 2 3 4
package iface

import (
	"context"
Łukasz Magiera's avatar
Łukasz Magiera committed
5
	"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
6

7 8
	"gx/ipfs/QmQ1JnYpnzkaurjW1yxkQxC2w3K1PorNE1nv1vaP5Le7sq/go-unixfs/pb"
	ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format"
Łukasz Magiera's avatar
Łukasz Magiera committed
9
	"gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files"
10 11
)

12 13
type AddEvent struct {
	Name  string
14 15 16
	Path  ResolvedPath `json:",omitempty"`
	Bytes int64        `json:",omitempty"`
	Size  string       `json:",omitempty"`
17 18
}

19 20 21 22 23 24 25 26
type LsLink struct {
	Link *ipld.Link
	Size uint64
	Type unixfs_pb.Data_DataType

	Err error
}

27
// UnixfsAPI is the basic interface to immutable files in IPFS
28
// NOTE: This API is heavily WIP, things are guaranteed to break frequently
29 30
type UnixfsAPI interface {
	// Add imports the data from the reader into merkledag file
Łukasz Magiera's avatar
Łukasz Magiera committed
31 32
	//
	// TODO: a long useful comment on how to use this for many different scenarios
33
	Add(context.Context, files.Node, ...options.UnixfsAddOption) (ResolvedPath, error)
34

Łukasz Magiera's avatar
Łukasz Magiera committed
35 36 37 38
	// Get returns a read-only handle to a file tree referenced by a path
	//
	// Note that some implementations of this API may apply the specified context
	// to operations performed on the returned file
39
	Get(context.Context, Path) (files.Node, error)
Łukasz Magiera's avatar
Łukasz Magiera committed
40

41 42
	// Ls returns the list of links in a directory. Links aren't guaranteed to be
	// returned in order
43
	Ls(context.Context, Path, ...options.UnixfsLsOption) (<-chan LsLink, error)
44
}