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
ld
go-ld-prime
Commits
8fa241ea
Commit
8fa241ea
authored
Dec 27, 2020
by
Eric Myhre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update a few more lingering ReprKind references.
parent
4dc68933
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
28 deletions
+28
-28
doc/nodes.md
doc/nodes.md
+5
-5
node/mixins/tmplMixin.txt
node/mixins/tmplMixin.txt
+21
-21
schema/gen/go/HACKME_maybe.md
schema/gen/go/HACKME_maybe.md
+2
-2
No files found.
doc/nodes.md
View file @
8fa241ea
...
...
@@ -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.
Repr
Kind`
-- 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.
Repr
Kind()`
method returns an
`ipld.
Repr
Kind`
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
`
Repr
Kind() == ipld.
Repr
Kind_Map`
,
and
`LookupByString`
is definitely going to error if
`
Repr
Kind() == ipld.
Repr
Kind_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
Repr
Kind
](
https://godoc.org/github.com/ipld/go-ipld-prime#
Repr
Kind
)
.
See the
[
godocs for Kind
](
https://godoc.org/github.com/ipld/go-ipld-prime#Kind
)
.
Node implementations
...
...
node/mixins/tmplMixin.txt
View file @
8fa241ea
...
...
@@ -23,20 +23,20 @@ type @Kind@ struct {
TypeName string
}
func (@Kind@)
Repr
Kind() ipld.
Repr
Kind {
return ipld.
Repr
Kind_@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.
Repr
KindSet_JustMap, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustMap, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustList, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_Recursive, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustBool, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustInt, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustFloat, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustString, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustBytes, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustLink, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustMap, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustList, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustNull, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustBool, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustInt, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustFloat, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustString, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustBytes, ActualKind: ipld.
Repr
Kind_@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.
Repr
KindSet_JustLink, ActualKind: ipld.
Repr
Kind_@Kind@}
return ipld.ErrWrongKind{TypeName: x.TypeName, MethodName: "AssignLink", AppropriateKind: ipld.KindSet_JustLink, ActualKind: ipld.Kind_@Kind@}
}
schema/gen/go/HACKME_maybe.md
View file @
8fa241ea
...
...
@@ -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.
Repr
Kind_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.
Repr
Kind_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.
...
...
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