Commit b98d1ef0 authored by Eric Myhre's avatar Eric Myhre

plainMap__KeyAssembler should use string mixin.

It's clearly a string in all behavioral ways.

I do pause to wonder if a different "TypeName" should be used here to
provide more indication of context.  I don't have a strong argument
one way or another.  Leaning against it by default, since so far when
I've had questions about "should I make child assemblers announce
their specialness" it has usually seemed to shake out to "no".
parent 66e36be2
...@@ -264,12 +264,24 @@ func (plainMap__Assembler) ValueStyle() ipld.NodeStyle { panic("later") } ...@@ -264,12 +264,24 @@ func (plainMap__Assembler) ValueStyle() ipld.NodeStyle { panic("later") }
// -- MapNodeAssembler.KeyAssembler --> // -- MapNodeAssembler.KeyAssembler -->
func (plainMap__KeyAssembler) BeginMap(sizeHint int) (ipld.MapNodeAssembler, error) { panic("no") } func (plainMap__KeyAssembler) BeginMap(sizeHint int) (ipld.MapNodeAssembler, error) {
func (plainMap__KeyAssembler) BeginList(sizeHint int) (ipld.ListNodeAssembler, error) { panic("no") } return mixins.StringAssembler{"string"}.BeginMap(0)
func (plainMap__KeyAssembler) AssignNull() error { panic("no") } }
func (plainMap__KeyAssembler) AssignBool(bool) error { panic("no") } func (plainMap__KeyAssembler) BeginList(sizeHint int) (ipld.ListNodeAssembler, error) {
func (plainMap__KeyAssembler) AssignInt(int) error { panic("no") } return mixins.StringAssembler{"string"}.BeginList(0)
func (plainMap__KeyAssembler) AssignFloat(float64) error { panic("no") } }
func (plainMap__KeyAssembler) AssignNull() error {
return mixins.StringAssembler{"string"}.AssignNull()
}
func (plainMap__KeyAssembler) AssignBool(bool) error {
return mixins.StringAssembler{"string"}.AssignBool(false)
}
func (plainMap__KeyAssembler) AssignInt(int) error {
return mixins.StringAssembler{"string"}.AssignInt(0)
}
func (plainMap__KeyAssembler) AssignFloat(float64) error {
return mixins.StringAssembler{"string"}.AssignFloat(0)
}
func (mka *plainMap__KeyAssembler) AssignString(v string) error { func (mka *plainMap__KeyAssembler) AssignString(v string) error {
// Check for dup keys; error if so. // Check for dup keys; error if so.
_, exists := mka.ma.w.m[v] _, exists := mka.ma.w.m[v]
...@@ -286,7 +298,9 @@ func (mka *plainMap__KeyAssembler) AssignString(v string) error { ...@@ -286,7 +298,9 @@ func (mka *plainMap__KeyAssembler) AssignString(v string) error {
mka.ma = nil // invalidate self to prevent further incorrect use. mka.ma = nil // invalidate self to prevent further incorrect use.
return nil return nil
} }
func (plainMap__KeyAssembler) AssignBytes([]byte) error { panic("no") } func (plainMap__KeyAssembler) AssignBytes([]byte) error {
return mixins.StringAssembler{"string"}.AssignBytes(nil)
}
func (mka *plainMap__KeyAssembler) AssignNode(v ipld.Node) error { func (mka *plainMap__KeyAssembler) AssignNode(v ipld.Node) error {
vs, err := v.AsString() vs, err := v.AsString()
if err != nil { if err != nil {
......
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