From 2dd511f989f5843155c9e0cf0dd94a0d9a97d036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 20 Apr 2018 13:56:33 +0200 Subject: [PATCH] coreapi: add more docs for path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- core/coreapi/interface/path.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/core/coreapi/interface/path.go b/core/coreapi/interface/path.go index e50f102dc82..f9a68182763 100644 --- a/core/coreapi/interface/path.go +++ b/core/coreapi/interface/path.go @@ -17,7 +17,9 @@ type Path interface { // String returns the path as a string. String() string - // Namespace returns the first component of the path + // Namespace returns the first component of the path. + // + // For example path "/ipfs/QmHash", calling Namespace() will return "ipfs" Namespace() string // Mutable returns false if the data pointed to by this path in guaranteed @@ -29,13 +31,29 @@ type Path interface { // ResolvedPath is a resolved Path type ResolvedPath interface { - // Cid returns the CID referred to by path + // Cid returns the CID of the object referenced by the path. + // + // Example: + // If you have 3 linked objects: QmRoot -> A -> B, and resolve path + // "/ipfs/QmRoot/A/B", the Cid method will return the CID of object B Cid() *cid.Cid - // Root returns the CID of root path + // Root returns the CID of the root object of the path + // + // Example: + // 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 Root() *cid.Cid // Remainder returns unresolved part of the path + // + // Example: + // If you have 2 linked objects: QmRoot -> A, where A is a CBOR node + // containing the following data: + // + // {"foo": {"bar": 42}} + // + // When resolving "/ipld/QmRoot/A/foo/bar", Remainder will return "foo/bar" Remainder() string Path