// Package iface defines IPFS Core API which is a set of interfaces used to // interact with IPFS nodes. package iface import ( "context" "errors" "io" cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" ipld "gx/ipfs/QmPN7cwmpcc4DWXb4KTB9dNAJgjuPY69h3npsMfhRrQL9c/go-ipld-format" ) // Path is a generic wrapper for paths used in the API. A path can be resolved // to a CID using one of Resolve functions in the API. 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 } // CoreAPI defines an unified interface to IPFS for Go programs. type CoreAPI interface { // Unixfs returns an implementation of Unixfs API Unixfs() UnixfsAPI // ResolvePath resolves the path using Unixfs resolver ResolvePath(context.Context, Path) (Path, error) // ResolveNode resolves the path (if not resolved already) using Unixfs // resolver, gets and returns the resolved Node ResolveNode(context.Context, Path) (Node, error) } // UnixfsAPI is the basic interface to immutable files in IPFS type UnixfsAPI interface { // Add imports the data from the reader into merkledag file Add(context.Context, io.Reader) (Path, error) // Cat returns a reader for the file Cat(context.Context, Path) (Reader, error) // Ls returns the list of links in a directory 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")