Skip to content

Commit 2dd511f

Browse files
committed
coreapi: add more docs for path
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
1 parent b40c65c commit 2dd511f

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

core/coreapi/interface/path.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ type Path interface {
1717
// String returns the path as a string.
1818
String() string
1919

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"
2123
Namespace() string
2224

2325
// Mutable returns false if the data pointed to by this path in guaranteed
@@ -29,13 +31,29 @@ type Path interface {
2931

3032
// ResolvedPath is a resolved Path
3133
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
3339
Cid() *cid.Cid
3440

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
3646
Root() *cid.Cid
3747

3848
// 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"
3957
Remainder() string
4058

4159
Path

0 commit comments

Comments
 (0)