coreapi: get going, add Cat() and Ls()
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org> This commit was moved from ipfs/interface-go-ipfs-core@d6cc518f50f331dfd20dc79e87319f307fa2b5e7 This commit was moved from ipfs/boxo@9a989442e7cd6463a7473cf7d6ed03e823c8b38a
Lars Gierth committed
Sep 11, 2016 at 05:09 UTC
1e573836850aef678080d9b74e4780af612c98b6
1 file changed
+56
core/coreiface/interface.go
new
+56
@@ -0,0 +1,56 @@
1
+package iface
2
+
3
+import (
4
+ "context"
5
+ "errors"
6
+ "io"
7
+
8
+ cid "gx/ipfs/QmXfiyr2RWEXpVDdaYnD2HNiBk6UBddsvEP4RPfXb6nGqY/go-cid"
9
+)
10
+
11
+// type CoreAPI interface {
12
+// ID() CoreID
13
+// Version() CoreVersion
14
+// }
15
+
16
+type Link struct {
17
+ Name string
18
+ Size uint64
19
+ Cid *cid.Cid
20
+}
21
+
22
+type Reader interface {
23
+ io.ReadSeeker
24
+ io.Closer
25
+}
26
+
27
+type UnixfsAPI interface {
28
+ Cat(context.Context, string) (Reader, error)
29
+ Ls(context.Context, string) ([]*Link, error)
30
+}
31
+
32
+// type ObjectAPI interface {
33
+// New() (cid.Cid, Object)
34
+// Get(string) (Object, error)
35
+// Links(string) ([]*Link, error)
36
+// Data(string) (Reader, error)
37
+// Stat(string) (ObjectStat, error)
38
+// Put(Object) (cid.Cid, error)
39
+// SetData(string, Reader) (cid.Cid, error)
40
+// AppendData(string, Data) (cid.Cid, error)
41
+// AddLink(string, string, string) (cid.Cid, error)
42
+// RmLink(string, string) (cid.Cid, error)
43
+// }
44
+
45
+// type ObjectStat struct {
46
+// Cid cid.Cid
47
+// NumLinks int
48
+// BlockSize int
49
+// LinksSize int
50
+// DataSize int
51
+// CumulativeSize int
52
+// }
53
+
54
+var ErrIsDir = errors.New("object is a directory")
55
+var ErrIsNonDag = errors.New("not a merkledag object")
56
+var ErrOffline = errors.New("can't resolve, ipfs node is offline")