Commit 8fa241ea authored by Eric Myhre's avatar Eric Myhre

Update a few more lingering ReprKind references.

parent 4dc68933
......@@ -19,7 +19,7 @@ Overview of Important Types
- `ipld.Node` -- see the section on Nodes above; this is *the* interface.
- `ipld.NodeBuilder` -- an interface for building new Nodes.
- `ipld.ReprKind` -- this enumeration describes all the major kinds at the Data Model layer.
- `ipld.Kind` -- this enumeration describes all the major kinds at the Data Model layer.
- `fluent.Node` -- similar to `ipld.Node`, but methods don't return errors, instead
carrying them until actually checked and/or using panics, making them easy to compose
in long expressions. See the full page for [Fluent APIs](./fluent.md) for more.
......@@ -41,14 +41,14 @@ See the [godocs for Node](https://godoc.org/github.com/ipld/go-ipld-prime#Node).
### kinds
The `Node.ReprKind()` method returns an `ipld.ReprKind` enum value describing what
The `Node.Kind()` method returns an `ipld.Kind` enum value describing what
kind of data this node contains in terms of the IPLD Data Model.
The validity of many other methods can be anticipated by switching on the kind:
for example, `AsString` is definitely going to error if `ReprKind() == ipld.ReprKind_Map`,
and `LookupByString` is definitely going to error if `ReprKind() == ipld.ReprKind_String`.
for example, `AsString` is definitely going to error if `Kind() == ipld.Kind_Map`,
and `LookupByString` is definitely going to error if `Kind() == ipld.Kind_String`.
See the [godocs for ReprKind](https://godoc.org/github.com/ipld/go-ipld-prime#ReprKind).
See the [godocs for Kind](https://godoc.org/github.com/ipld/go-ipld-prime#Kind).
Node implementations
......
......@@ -23,20 +23,20 @@ type @Kind@ struct {
TypeName string
}
func (@Kind@) ReprKind() ipld.ReprKind {
return ipld.ReprKind_@Kind@
func (@Kind@) Kind() ipld.Kind {
return ipld.Kind_@Kind@
}
func (x @Kind@) LookupByString(string) (ipld.Node, error) {
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.ReprKindSet_JustMap, ActualKind: ipld.ReprKind_@Kind@}
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByString", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@) LookupByNode(key ipld.Node) (ipld.Node, error) {
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.ReprKindSet_JustMap, ActualKind: ipld.ReprKind_@Kind@}
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByNode", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@) LookupByIndex(idx int) (ipld.Node, error) {
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.ReprKindSet_JustList, ActualKind: ipld.ReprKind_@Kind@}
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupByIndex", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@) LookupBySegment(ipld.PathSegment) (ipld.Node, error) {
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: ipld.ReprKindSet_Recursive, ActualKind: ipld.ReprKind_@Kind@}
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "LookupBySegment", AppropriateKind: ipld.KindSet_Recursive, ActualKind: ipld.Kind_@Kind@}
}
func (@Kind@) MapIterator() ipld.MapIterator {
return nil
......@@ -54,22 +54,22 @@ func (@Kind@) IsNull() bool {
return false
}
func (x @Kind@) AsBool() (bool, error) {
return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.ReprKindSet_JustBool, ActualKind: ipld.ReprKind_@Kind@}
return false, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@) AsInt() (int, error) {
return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.ReprKindSet_JustInt, ActualKind: ipld.ReprKind_@Kind@}
return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@) AsFloat() (float64, error) {
return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.ReprKindSet_JustFloat, ActualKind: ipld.ReprKind_@Kind@}
return 0, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@) AsString() (string, error) {
return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.ReprKindSet_JustString, ActualKind: ipld.ReprKind_@Kind@}
return "", ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@) AsBytes() ([]byte, error) {
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.ReprKindSet_JustBytes, ActualKind: ipld.ReprKind_@Kind@}
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@) AsLink() (ipld.Link, error) {
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.ReprKindSet_JustLink, ActualKind: ipld.ReprKind_@Kind@}
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AsLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_@Kind@}
}
// @Kind@Assembler has similar purpose as @Kind@, but for (you guessed it)
......@@ -79,29 +79,29 @@ type @Kind@Assembler struct {
}
func (x @Kind@Assembler) BeginMap(sizeHint int) (ipld.MapAssembler, error) {
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.ReprKindSet_JustMap, ActualKind: ipld.ReprKind_@Kind@}
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginMap", AppropriateKind: ipld.KindSet_JustMap, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@Assembler) BeginList(sizeHint int) (ipld.ListAssembler, error) {
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.ReprKindSet_JustList, ActualKind: ipld.ReprKind_@Kind@}
return nil, ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "BeginList", AppropriateKind: ipld.KindSet_JustList, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@Assembler) AssignNull() error {
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.ReprKindSet_JustNull, ActualKind: ipld.ReprKind_@Kind@}
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignNull", AppropriateKind: ipld.KindSet_JustNull, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@Assembler) AssignBool(bool) error {
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.ReprKindSet_JustBool, ActualKind: ipld.ReprKind_@Kind@}
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBool", AppropriateKind: ipld.KindSet_JustBool, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@Assembler) AssignInt(int) error {
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.ReprKindSet_JustInt, ActualKind: ipld.ReprKind_@Kind@}
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignInt", AppropriateKind: ipld.KindSet_JustInt, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@Assembler) AssignFloat(float64) error {
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.ReprKindSet_JustFloat, ActualKind: ipld.ReprKind_@Kind@}
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignFloat", AppropriateKind: ipld.KindSet_JustFloat, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@Assembler) AssignString(string) error {
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.ReprKindSet_JustString, ActualKind: ipld.ReprKind_@Kind@}
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignString", AppropriateKind: ipld.KindSet_JustString, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@Assembler) AssignBytes([]byte) error {
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.ReprKindSet_JustBytes, ActualKind: ipld.ReprKind_@Kind@}
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignBytes", AppropriateKind: ipld.KindSet_JustBytes, ActualKind: ipld.Kind_@Kind@}
}
func (x @Kind@Assembler) AssignLink(ipld.Link) error {
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.ReprKindSet_JustLink, ActualKind: ipld.ReprKind_@Kind@}
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_@Kind@}
}
......@@ -41,7 +41,7 @@ The concept of "null" has a Kind in the IPLD Data Model.
It's implemented by the `ipld.nullNode` type (which has no fields -- it's a "unit" type),
and is exposed as the `ipld.Null` singleton value.
(More generally, `ipld.Node` can be null by having its `Kind()` method return `ipld.ReprKind_Null`,
(More generally, `ipld.Node` can be null by having its `Kind()` method return `ipld.Kind_Null`,
and having the `IsNull()` method return `true`.
However, most code prefers to return the `ipld.Null` singleton value whenever it can.)
......@@ -62,7 +62,7 @@ Absent is implemented by the `ipld.absentNode` type (which has no fields -- it's
and is exposed as the `ipld.Absent` singleton value.
(More generally, an `ipld.Node` can describe itself as containing "absent" by having the `IsAbsent()` method return `true`.
(The `Kind()` method still returns `ipld.ReprKind_Null`, for lack of better option.)
(The `Kind()` method still returns `ipld.Kind_Null`, for lack of better option.)
However, most code prefers to return the `ipld.Absent` singleton value whenever it can.)
Absent values aren't really used at the Data Model level.
......
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