1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-23 01:46:53 +08:00
Files
kubo/core/coreapi/interface/interface.go
Steven Allen 13636bef50 blocks: gx import go-block-format
And updated related dependencies.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2017-06-29 22:12:14 +02:00

65 lines
1.5 KiB
Go

package iface
import (
"context"
"errors"
"io"
cid "gx/ipfs/QmNw61A6sJoXMeP37mJRtQZdNhj5e3FdjoTN3v4FyE96Gk/go-cid"
ipld "gx/ipfs/QmUBtPvHKFAX43XMsyxsYpMi3U5VwZ4jYFTo4kFhvAR33G/go-ipld-format"
)
type Path interface {
String() string
Cid() *cid.Cid
Root() *cid.Cid
Resolved() bool
}
// TODO: should we really copy these?
// if we didn't, godoc would generate nice links straight to go-ipld-format
type Node ipld.Node
type Link ipld.Link
type Reader interface {
io.ReadSeeker
io.Closer
}
type CoreAPI interface {
Unixfs() UnixfsAPI
ResolvePath(context.Context, Path) (Path, error)
ResolveNode(context.Context, Path) (Node, error)
}
type UnixfsAPI interface {
Add(context.Context, io.Reader) (Path, error)
Cat(context.Context, Path) (Reader, error)
Ls(context.Context, Path) ([]*Link, error)
}
// type ObjectAPI interface {
// New() (cid.Cid, Object)
// Get(string) (Object, error)
// Links(string) ([]*Link, error)
// Data(string) (Reader, error)
// Stat(string) (ObjectStat, error)
// Put(Object) (cid.Cid, error)
// SetData(string, Reader) (cid.Cid, error)
// AppendData(string, Data) (cid.Cid, error)
// AddLink(string, string, string) (cid.Cid, error)
// RmLink(string, string) (cid.Cid, error)
// }
// type ObjectStat struct {
// Cid cid.Cid
// NumLinks int
// BlockSize int
// LinksSize int
// DataSize int
// CumulativeSize int
// }
var ErrIsDir = errors.New("object is a directory")
var ErrOffline = errors.New("can't resolve, ipfs node is offline")