coreapi: Basic object API implementation
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@52f5b7ce1f8cc0503ec9d9ce070afdee7997049c This commit was moved from ipfs/boxo@f10a09d9b25f8ec1a43f7e93f9fe182ca5ef82ff
Łukasz Magiera committed
Dec 14, 2017 at 23:55 UTC
9f5914daf7841d111ce090c3214a39035e653261
1 file changed
+23
-21
core/coreiface/interface.go
+23
-21
@@ -191,27 +191,29 @@ type KeyAPI interface {
191
Remove(ctx context.Context, name string) (Path, error)
192
}
193
194
-// type ObjectAPI interface {
195
-// New() (cid.Cid, Object)
196
-// Get(string) (Object, error)
197
-// Links(string) ([]*Link, error)
198
-// Data(string) (Reader, error)
199
-// Stat(string) (ObjectStat, error)
200
-// Put(Object) (cid.Cid, error)
201
-// SetData(string, Reader) (cid.Cid, error)
202
-// AppendData(string, Data) (cid.Cid, error)
203
-// AddLink(string, string, string) (cid.Cid, error)
204
-// RmLink(string, string) (cid.Cid, error)
205
-// }
206
-
207
-// type ObjectStat struct {
208
-// Cid cid.Cid
209
-// NumLinks int
210
-// BlockSize int
211
-// LinksSize int
212
-// DataSize int
213
-// CumulativeSize int
214
-// }
194
+//TODO: Should this use paths instead of cids?
195
+type ObjectAPI interface {
196
+ New(ctx context.Context) (Node, error)
197
+ Put(context.Context, Node) error
198
+ Get(context.Context, Path) (Node, error)
199
+ Data(context.Context, Path) (io.Reader, error)
200
+ Links(context.Context, Path) ([]*Link, error)
201
+ Stat(context.Context, Path) (*ObjectStat, error)
202
+
203
+ AddLink(ctx context.Context, base Path, name string, child Path, create bool) (Node, error) //TODO: make create optional
204
+ RmLink(context.Context, Path, string) (Node, error)
205
+ AppendData(context.Context, Path, io.Reader) (Node, error)
206
+ SetData(context.Context, Path, io.Reader) (Node, error)
207
+}
208
+
209
+type ObjectStat struct {
210
+ Cid *cid.Cid
211
+ NumLinks int
212
+ BlockSize int
213
+ LinksSize int
214
+ DataSize int
215
+ CumulativeSize int
216
+}
217
218
var ErrIsDir = errors.New("object is a directory")
219
var ErrOffline = errors.New("can't resolve, ipfs node is offline")