Commit 025fcf8a authored by Eric Myhre's avatar Eric Myhre

Add NodeBuilder to Node interface.

(... offically.  Lots of docs have probably already been stating that
this is there.  Now it actually... is.)
Signed-off-by: default avatarEric Myhre <hash@exultant.us>
parent 6428f14f
......@@ -103,6 +103,10 @@ func (n Node) AsLink() (v ipld.Link, _ error) {
return
}
func (n Node) NodeBuilder() ipld.NodeBuilder {
panic("NYI")
}
func (n Node) Keys() ipld.KeyIterator {
panic("NYI")
}
......
......@@ -65,6 +65,10 @@ func (n *Node) AsLink() (v ipld.Link, _ error) {
return n._link, expectTyp(ipld.ReprKind_Link, n.kind)
}
func (n *Node) NodeBuilder() ipld.NodeBuilder {
return nodeBuilder{n}
}
func (n *Node) Keys() ipld.KeyIterator {
return &keyIterator{n, 0}
}
......
......@@ -63,6 +63,20 @@ type Node interface {
AsString() (string, error)
AsBytes() ([]byte, error)
AsLink() (Link, error)
// NodeBuilder returns a NodeBuilder which can be used to build
// new nodes of the same implementation type as this one.
//
// For map and list nodes, the NodeBuilder's append-oriented methods
// will work using this node's values as a base.
// If this is a typed node, the NodeBuilder will carry the same
// typesystem constraints as this Node.
//
// (This feature is used by the traversal package, especially in
// e.g. traversal.Transform, for doing tree updates while keeping the
// existing implementation preferences and doing as many operations
// in copy-on-write fashions as possible.)
NodeBuilder() NodeBuilder
}
// KeyIterator is an interface for traversing nodes of kind map.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment