Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
1806f0f9
Commit
1806f0f9
authored
Jun 12, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi: more docs for ResolvedPath
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
5abaad9e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
6 deletions
+35
-6
path.go
path.go
+35
-6
No files found.
path.go
View file @
1806f0f9
...
@@ -29,13 +29,38 @@ type Path interface {
...
@@ -29,13 +29,38 @@ type Path interface {
Mutable
()
bool
Mutable
()
bool
}
}
// ResolvedPath is a
resolved Path
// ResolvedPath is a
path which was resolved to the last resolvable node
type
ResolvedPath
interface
{
type
ResolvedPath
interface
{
// Cid returns the CID of the object referenced by the path.
// Cid returns the CID of the node referenced by the path. Remainder of the
// path is guaranteed to be within the node.
//
//
// Example:
// Examples:
// If you have 3 linked objects: QmRoot -> A -> B, and resolve path
// If you have 3 linked objects: QmRoot -> A -> B:
// "/ipfs/QmRoot/A/B", the Cid method will return the CID of object B
//
// cidB := {"foo": {"bar": 42 }}
// cidA := {"B": {"/": cidB }}
// cidRoot := {"A": {"/": cidA }}
//
// And resolve paths:
// * "/ipfs/${cidRoot}"
// * Calling Cid() will return `cidRoot`
// * Calling Root() will return `cidRoot`
// * Calling Remainder() will return ``
//
// * "/ipfs/${cidRoot}/A"
// * Calling Cid() will return `cidA`
// * Calling Root() will return `cidRoot`
// * Calling Remainder() will return ``
//
// * "/ipfs/${cidRoot}/A/B/foo"
// * Calling Cid() will return `cidB`
// * Calling Root() will return `cidRoot`
// * Calling Remainder() will return `foo`
//
// * "/ipfs/${cidRoot}/A/B/foo/bar"
// * Calling Cid() will return `cidB`
// * Calling Root() will return `cidRoot`
// * Calling Remainder() will return `foo/bar`
Cid
()
*
cid
.
Cid
Cid
()
*
cid
.
Cid
// Root returns the CID of the root object of the path
// Root returns the CID of the root object of the path
...
@@ -43,6 +68,8 @@ type ResolvedPath interface {
...
@@ -43,6 +68,8 @@ type ResolvedPath interface {
// Example:
// Example:
// If you have 3 linked objects: QmRoot -> A -> B, and resolve path
// If you have 3 linked objects: QmRoot -> A -> B, and resolve path
// "/ipfs/QmRoot/A/B", the Root method will return the CID of object QmRoot
// "/ipfs/QmRoot/A/B", the Root method will return the CID of object QmRoot
//
// For more examples see the documentation of Cid() method
Root
()
*
cid
.
Cid
Root
()
*
cid
.
Cid
// Remainder returns unresolved part of the path
// Remainder returns unresolved part of the path
...
@@ -51,9 +78,11 @@ type ResolvedPath interface {
...
@@ -51,9 +78,11 @@ type ResolvedPath interface {
// If you have 2 linked objects: QmRoot -> A, where A is a CBOR node
// If you have 2 linked objects: QmRoot -> A, where A is a CBOR node
// containing the following data:
// containing the following data:
//
//
// {"foo": {"bar": 42}}
// {"foo": {"bar": 42
}}
//
//
// When resolving "/ipld/QmRoot/A/foo/bar", Remainder will return "foo/bar"
// When resolving "/ipld/QmRoot/A/foo/bar", Remainder will return "foo/bar"
//
// For more examples see the documentation of Cid() method
Remainder
()
string
Remainder
()
string
Path
Path
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment