@cryptotaxi247 / kubo / commits / 66f305fb5

docs/coreapi: Add some documentation to CoreAPI

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@2fbdcd09c87e05ff355b4a492b01029273b1f0f3 This commit was moved from ipfs/boxo@9cc221d2ae772fe67425e873db64516bf1bf1f40

Łukasz Magiera committed Dec 15, 2017 at 01:34 UTC 66f305fb517f962ad64a1aa92f4702c4d2b043f4
1 file changed +17
core/coreiface/interface.go
+17
@@ -1,3 +1,5 @@
1 +// Package iface defines IPFS Core API which is a set of interfaces used to
2 +// interact with IPFS nodes.
3 package iface
4
5 import (
@@ -9,6 +11,8 @@ import (
11 ipld "gx/ipfs/QmPN7cwmpcc4DWXb4KTB9dNAJgjuPY69h3npsMfhRrQL9c/go-ipld-format"
12 )
13
14 +// Path is a generic wrapper for paths used in the API. A path can be resolved
15 +// to a CID using one of Resolve functions in the API.
16 type Path interface {
17 String() string
18 Cid() *cid.Cid
@@ -26,15 +30,28 @@ type Reader interface {
30 io.Closer
31 }
32
33 +// CoreAPI defines an unified interface to IPFS for Go programs.
34 type CoreAPI interface {
35 + // Unixfs returns an implementation of Unixfs API
36 Unixfs() UnixfsAPI
37 +
38 + // ResolvePath resolves the path using Unixfs resolver
39 ResolvePath(context.Context, Path) (Path, error)
40 +
41 + // ResolveNode resolves the path (if not resolved already) using Unixfs
42 + // resolver, gets and returns the resolved Node
43 ResolveNode(context.Context, Path) (Node, error)
44 }
45
46 +// UnixfsAPI is the basic interface to immutable files in IPFS
47 type UnixfsAPI interface {
48 + // Add imports the data from the reader into merkledag file
49 Add(context.Context, io.Reader) (Path, error)
50 +
51 + // Cat returns a reader for the file
52 Cat(context.Context, Path) (Reader, error)
53 +
54 + // Ls returns the list of links in a directory
55 Ls(context.Context, Path) ([]*Link, error)
56 }
57