coreapi: add more docs for path
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Apr 20, 2018 at 13:56 UTC
d5b5e0d7ac73fbeeed78b81af25dfb5e8555a308
1 file changed
+21
-3
core/coreapi/interface/path.go
+21
-3
@@ -17,7 +17,9 @@ type Path interface {
17
// String returns the path as a string.
18
String() string
19
20
- // Namespace returns the first component of the path
20
+ // Namespace returns the first component of the path.
21
+ //
22
+ // For example path "/ipfs/QmHash", calling Namespace() will return "ipfs"
23
Namespace() string
24
25
// Mutable returns false if the data pointed to by this path in guaranteed
@@ -29,13 +31,29 @@ type Path interface {
31
32
// ResolvedPath is a resolved Path
33
type ResolvedPath interface {
32
- // Cid returns the CID referred to by path
34
+ // Cid returns the CID of the object referenced by the path.
35
+ //
36
+ // Example:
37
+ // If you have 3 linked objects: QmRoot -> A -> B, and resolve path
38
+ // "/ipfs/QmRoot/A/B", the Cid method will return the CID of object B
39
Cid() *cid.Cid
40
35
- // Root returns the CID of root path
41
+ // Root returns the CID of the root object of the path
42
+ //
43
+ // Example:
44
+ // If you have 3 linked objects: QmRoot -> A -> B, and resolve path
45
+ // "/ipfs/QmRoot/A/B", the Root method will return the CID of object QmRoot
46
Root() *cid.Cid
47
48
// Remainder returns unresolved part of the path
49
+ //
50
+ // Example:
51
+ // If you have 2 linked objects: QmRoot -> A, where A is a CBOR node
52
+ // containing the following data:
53
+ //
54
+ // {"foo": {"bar": 42}}
55
+ //
56
+ // When resolving "/ipld/QmRoot/A/foo/bar", Remainder will return "foo/bar"
57
Remainder() string
58
59
Path