@@ -16,15 +16,26 @@ import (
16
16
17
17
// Path is a generic wrapper for paths used in the API. A path can be resolved
18
18
// to a CID using one of Resolve functions in the API.
19
+ // TODO: figure out/explain namespaces
19
20
type Path interface {
20
21
// String returns the path as a string.
21
22
String () string
23
+
24
+ // Namespace returns the first component of the path
25
+ Namespace () string
26
+ }
27
+
28
+ // ResolvedPath is a resolved Path
29
+ type ResolvedPath interface {
22
30
// Cid returns cid referred to by path
23
31
Cid () * cid.Cid
32
+
24
33
// Root returns cid of root path
25
34
Root () * cid.Cid
26
- // Resolved returns whether path has been fully resolved
27
- Resolved () bool
35
+
36
+ //TODO: Path remainder
37
+
38
+ Path
28
39
}
29
40
30
41
// TODO: should we really copy these?
@@ -61,7 +72,7 @@ type BlockStat interface {
61
72
// Pin holds information about pinned resource
62
73
type Pin interface {
63
74
// Path to the pinned object
64
- Path () Path
75
+ Path () ResolvedPath
65
76
66
77
// Type of the pin
67
78
Type () string
@@ -79,7 +90,7 @@ type PinStatus interface {
79
90
// BadPinNode is a node that has been marked as bad by Pin.Verify
80
91
type BadPinNode interface {
81
92
// Path is the path of the node
82
- Path () Path
93
+ Path () ResolvedPath
83
94
84
95
// Err is the reason why the node has been marked as bad
85
96
Err () error
@@ -101,33 +112,31 @@ type CoreAPI interface {
101
112
102
113
// Key returns an implementation of Key API.
103
114
Key () KeyAPI
115
+
116
+ // Pin returns an implementation of Pin API
104
117
Pin () PinAPI
105
118
106
119
// ObjectAPI returns an implementation of Object API
107
120
Object () ObjectAPI
108
121
109
122
// ResolvePath resolves the path using Unixfs resolver
110
- ResolvePath (context.Context , Path ) (Path , error )
123
+ ResolvePath (context.Context , Path ) (ResolvedPath , error )
111
124
112
125
// ResolveNode resolves the path (if not resolved already) using Unixfs
113
126
// resolver, gets and returns the resolved Node
114
127
ResolveNode (context.Context , Path ) (Node , error )
115
128
116
129
// ParsePath parses string path to a Path
117
- ParsePath (context.Context , string , ... options.ParsePathOption ) (Path , error )
118
-
119
- // WithResolve is an option for ParsePath which when set to true tells
120
- // ParsePath to also resolve the path
121
- WithResolve (bool ) options.ParsePathOption
130
+ ParsePath (string ) (Path , error )
122
131
123
132
// ParseCid creates new path from the provided CID
124
- ParseCid (* cid.Cid ) Path
133
+ ParseCid (* cid.Cid ) ResolvedPath
125
134
}
126
135
127
136
// UnixfsAPI is the basic interface to immutable files in IPFS
128
137
type UnixfsAPI interface {
129
138
// Add imports the data from the reader into merkledag file
130
- Add (context.Context , io.Reader ) (Path , error )
139
+ Add (context.Context , io.Reader ) (ResolvedPath , error )
131
140
132
141
// Cat returns a reader for the file
133
142
Cat (context.Context , Path ) (Reader , error )
@@ -139,7 +148,7 @@ type UnixfsAPI interface {
139
148
// BlockAPI specifies the interface to the block layer
140
149
type BlockAPI interface {
141
150
// Put imports raw block data, hashing it using specified settings.
142
- Put (context.Context , io.Reader , ... options.BlockPutOption ) (Path , error )
151
+ Put (context.Context , io.Reader , ... options.BlockPutOption ) (ResolvedPath , error )
143
152
144
153
// WithFormat is an option for Put which specifies the multicodec to use to
145
154
// serialize the object. Default is "v0"
@@ -173,7 +182,7 @@ type DagAPI interface {
173
182
// Put inserts data using specified format and input encoding.
174
183
// Unless used with WithCodec or WithHash, the defaults "dag-cbor" and
175
184
// "sha256" are used.
176
- Put (ctx context.Context , src io.Reader , opts ... options.DagPutOption ) (Path , error )
185
+ Put (ctx context.Context , src io.Reader , opts ... options.DagPutOption ) (ResolvedPath , error )
177
186
178
187
// WithInputEnc is an option for Put which specifies the input encoding of the
179
188
// data. Default is "json", most formats/codecs support "raw"
@@ -290,13 +299,13 @@ type ObjectAPI interface {
290
299
WithType (string ) options.ObjectNewOption
291
300
292
301
// Put imports the data into merkledag
293
- Put (context.Context , io.Reader , ... options.ObjectPutOption ) (Path , error )
302
+ Put (context.Context , io.Reader , ... options.ObjectPutOption ) (ResolvedPath , error )
294
303
295
304
// WithInputEnc is an option for Put which specifies the input encoding of the
296
305
// data. Default is "json".
297
306
//
298
307
// Supported encodings:
299
- // * "protobuf"
308
+ // * "protobuf"reselved version of Path
300
309
// * "json"
301
310
WithInputEnc (e string ) options.ObjectPutOption
302
311
@@ -323,20 +332,20 @@ type ObjectAPI interface {
323
332
// AddLink adds a link under the specified path. child path can point to a
324
333
// subdirectory within the patent which must be present (can be overridden
325
334
// with WithCreate option).
326
- AddLink (ctx context.Context , base Path , name string , child Path , opts ... options.ObjectAddLinkOption ) (Path , error )
335
+ AddLink (ctx context.Context , base Path , name string , child Path , opts ... options.ObjectAddLinkOption ) (ResolvedPath , error )
327
336
328
337
// WithCreate is an option for AddLink which specifies whether create required
329
338
// directories for the child
330
339
WithCreate (create bool ) options.ObjectAddLinkOption
331
340
332
341
// RmLink removes a link from the node
333
- RmLink (ctx context.Context , base Path , link string ) (Path , error )
342
+ RmLink (ctx context.Context , base Path , link string ) (ResolvedPath , error )
334
343
335
344
// AppendData appends data to the node
336
- AppendData (context.Context , Path , io.Reader ) (Path , error )
345
+ AppendData (context.Context , Path , io.Reader ) (ResolvedPath , error )
337
346
338
347
// SetData sets the data contained in the node
339
- SetData (context.Context , Path , io.Reader ) (Path , error )
348
+ SetData (context.Context , Path , io.Reader ) (ResolvedPath , error )
340
349
}
341
350
342
351
// ObjectStat provides information about dag nodes
0 commit comments