@@ -16,15 +16,26 @@ import (
1616
1717// Path is a generic wrapper for paths used in the API. A path can be resolved
1818// to a CID using one of Resolve functions in the API.
19+ // TODO: figure out/explain namespaces
1920type Path interface {
2021 // String returns the path as a string.
2122 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 {
2230 // Cid returns cid referred to by path
2331 Cid () * cid.Cid
32+
2433 // Root returns cid of root path
2534 Root () * cid.Cid
26- // Resolved returns whether path has been fully resolved
27- Resolved () bool
35+
36+ //TODO: Path remainder
37+
38+ Path
2839}
2940
3041// TODO: should we really copy these?
@@ -61,7 +72,7 @@ type BlockStat interface {
6172// Pin holds information about pinned resource
6273type Pin interface {
6374 // Path to the pinned object
64- Path () Path
75+ Path () ResolvedPath
6576
6677 // Type of the pin
6778 Type () string
@@ -79,7 +90,7 @@ type PinStatus interface {
7990// BadPinNode is a node that has been marked as bad by Pin.Verify
8091type BadPinNode interface {
8192 // Path is the path of the node
82- Path () Path
93+ Path () ResolvedPath
8394
8495 // Err is the reason why the node has been marked as bad
8596 Err () error
@@ -101,33 +112,31 @@ type CoreAPI interface {
101112
102113 // Key returns an implementation of Key API.
103114 Key () KeyAPI
115+
116+ // Pin returns an implementation of Pin API
104117 Pin () PinAPI
105118
106119 // ObjectAPI returns an implementation of Object API
107120 Object () ObjectAPI
108121
109122 // ResolvePath resolves the path using Unixfs resolver
110- ResolvePath (context.Context , Path ) (Path , error )
123+ ResolvePath (context.Context , Path ) (ResolvedPath , error )
111124
112125 // ResolveNode resolves the path (if not resolved already) using Unixfs
113126 // resolver, gets and returns the resolved Node
114127 ResolveNode (context.Context , Path ) (Node , error )
115128
116129 // 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 )
122131
123132 // ParseCid creates new path from the provided CID
124- ParseCid (* cid.Cid ) Path
133+ ParseCid (* cid.Cid ) ResolvedPath
125134}
126135
127136// UnixfsAPI is the basic interface to immutable files in IPFS
128137type UnixfsAPI interface {
129138 // 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 )
131140
132141 // Cat returns a reader for the file
133142 Cat (context.Context , Path ) (Reader , error )
@@ -139,7 +148,7 @@ type UnixfsAPI interface {
139148// BlockAPI specifies the interface to the block layer
140149type BlockAPI interface {
141150 // 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 )
143152
144153 // WithFormat is an option for Put which specifies the multicodec to use to
145154 // serialize the object. Default is "v0"
@@ -173,7 +182,7 @@ type DagAPI interface {
173182 // Put inserts data using specified format and input encoding.
174183 // Unless used with WithCodec or WithHash, the defaults "dag-cbor" and
175184 // "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 )
177186
178187 // WithInputEnc is an option for Put which specifies the input encoding of the
179188 // data. Default is "json", most formats/codecs support "raw"
@@ -290,13 +299,13 @@ type ObjectAPI interface {
290299 WithType (string ) options.ObjectNewOption
291300
292301 // 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 )
294303
295304 // WithInputEnc is an option for Put which specifies the input encoding of the
296305 // data. Default is "json".
297306 //
298307 // Supported encodings:
299- // * "protobuf"
308+ // * "protobuf"reselved version of Path
300309 // * "json"
301310 WithInputEnc (e string ) options.ObjectPutOption
302311
@@ -323,20 +332,20 @@ type ObjectAPI interface {
323332 // AddLink adds a link under the specified path. child path can point to a
324333 // subdirectory within the patent which must be present (can be overridden
325334 // 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 )
327336
328337 // WithCreate is an option for AddLink which specifies whether create required
329338 // directories for the child
330339 WithCreate (create bool ) options.ObjectAddLinkOption
331340
332341 // 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 )
334343
335344 // AppendData appends data to the node
336- AppendData (context.Context , Path , io.Reader ) (Path , error )
345+ AppendData (context.Context , Path , io.Reader ) (ResolvedPath , error )
337346
338347 // 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 )
340349}
341350
342351// ObjectStat provides information about dag nodes
0 commit comments