From 9b3162799b2598bfcecae988b6c7ffc23d4d92fe Mon Sep 17 00:00:00 2001 From: galargh Date: Thu, 1 Sep 2022 17:31:17 +0200 Subject: [PATCH 1/4] chore: replace deprecated ioutil with io/os --- blueprints/base/services.go | 2 +- .../services/dagjson-over-http/server.go | 4 +- codegen/file.go | 3 +- .../gen-routing-api/proto/proto_edelweiss.go | 1315 ++++++------ .../api/proto/proto_edelweiss.go | 1912 ++++++++--------- test/harness.go | 5 +- 6 files changed, 1582 insertions(+), 1659 deletions(-) diff --git a/blueprints/base/services.go b/blueprints/base/services.go index 3e7db4e..c2292ca 100644 --- a/blueprints/base/services.go +++ b/blueprints/base/services.go @@ -29,7 +29,7 @@ var ( IOReadCloser = &cg.GoRef{PkgPath: "io", Name: "ReadCloser"} IOEOF = &cg.GoRef{PkgPath: "io", Name: "EOF"} IOErrUnexpectedEOF = &cg.GoRef{PkgPath: "io", Name: "ErrUnexpectedEOF"} - IOUtilReadAll = &cg.GoRef{PkgPath: "io/ioutil", Name: "ReadAll"} + IOReadAll = &cg.GoRef{PkgPath: "io", Name: "ReadAll"} ) const EdelweissServicesPkg = services.PkgPath diff --git a/blueprints/services/dagjson-over-http/server.go b/blueprints/services/dagjson-over-http/server.go index 68eebf6..87dd6f3 100644 --- a/blueprints/services/dagjson-over-http/server.go +++ b/blueprints/services/dagjson-over-http/server.go @@ -138,7 +138,7 @@ func (x GoServerImpl) GoDef() cg.Blueprint { "HTTPResponseWriter": base.HTTPResponseWriter, "IPLDDecode": base.IPLDDecode, "DAGJSONDecode": base.DAGJSONDecode, - "IOUtilReadAll": base.IOUtilReadAll, + "IOReadAll": base.IOReadAll, // "Interface": x.Ref.Append("_Server"), "AsyncHandler": x.Ref.Append("_AsyncHandler"), @@ -168,7 +168,7 @@ type {{.Interface}} interface { func {{.AsyncHandler}}(s {{.Interface}}) {{.HTTPHandlerFunc}} { return func(writer {{.HTTPResponseWriter}}, request *{{.HTTPRequest}}) { // parse request - msg, err := {{.IOUtilReadAll}}(request.Body) + msg, err := {{.IOReadAll}}(request.Body) if err != nil { {{.LoggerVar}}.Errorf("reading request body (%v)", err) writer.WriteHeader(400) diff --git a/codegen/file.go b/codegen/file.go index 76171b0..7a7d2a4 100644 --- a/codegen/file.go +++ b/codegen/file.go @@ -3,7 +3,6 @@ package codegen import ( "bytes" "fmt" - "io/ioutil" "os" "path" ) @@ -28,7 +27,7 @@ func (f *GoFile) Build() error { if err != nil { return err } - return ioutil.WriteFile(f.FilePath, body, 0644) + return os.WriteFile(f.FilePath, body, 0644) } func (f *GoFile) Generate() ([]byte, error) { diff --git a/examples/gen-routing-api/proto/proto_edelweiss.go b/examples/gen-routing-api/proto/proto_edelweiss.go index 116347f..3bc6f48 100644 --- a/examples/gen-routing-api/proto/proto_edelweiss.go +++ b/examples/gen-routing-api/proto/proto_edelweiss.go @@ -2,46 +2,48 @@ package proto -import ( +import( + pd1 "github.com/ipld/edelweiss/values" + pd2 "fmt" + pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd4 "net/http" + pd5 "github.com/ipfs/go-log/v2" pd6 "bytes" - pd8 "context" - pd11 "errors" - pd3 "fmt" - pd7 "io" - pd15 "io/ioutil" - pd12 "net/http" - pd10 "net/url" - pd14 "sync" - - pd4 "github.com/ipfs/go-log/v2" + pd7 "context" + pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd9 "errors" + pd10 "io" + pd11 "github.com/ipld/go-ipld-prime" + pd12 "net/url" pd13 "github.com/ipld/edelweiss/services" - pd1 "github.com/ipld/edelweiss/values" - pd9 "github.com/ipld/go-ipld-prime" - pd5 "github.com/ipld/go-ipld-prime/codec/dagjson" - pd2 "github.com/ipld/go-ipld-prime/datamodel" + pd14 "sync" ) + // -- protocol type DelegatedRouting_IdentifyArg -- type DelegatedRouting_IdentifyArg struct { + } -func (x DelegatedRouting_IdentifyArg) Node() pd2.Node { +func (x DelegatedRouting_IdentifyArg) Node() pd3.Node { return x } -func (x *DelegatedRouting_IdentifyArg) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *DelegatedRouting_IdentifyArg) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{ + + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { @@ -51,7 +53,7 @@ func (x *DelegatedRouting_IdentifyArg) Parse(n pd2.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -63,7 +65,7 @@ type DelegatedRouting_IdentifyArg_MapIterator struct { s *DelegatedRouting_IdentifyArg } -func (x *DelegatedRouting_IdentifyArg_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *DelegatedRouting_IdentifyArg_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { @@ -72,29 +74,29 @@ func (x *DelegatedRouting_IdentifyArg_MapIterator) Next() (key pd2.Node, value p } func (x *DelegatedRouting_IdentifyArg_MapIterator) Done() bool { - return x.i+1 >= 0 + return x.i + 1 >= 0 } -func (x DelegatedRouting_IdentifyArg) Kind() pd2.Kind { - return pd2.Kind_Map +func (x DelegatedRouting_IdentifyArg) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x DelegatedRouting_IdentifyArg) LookupByString(key string) (pd2.Node, error) { +func (x DelegatedRouting_IdentifyArg) LookupByString(key string) (pd3.Node, error) { switch key { } return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x DelegatedRouting_IdentifyArg) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -104,25 +106,25 @@ func (x DelegatedRouting_IdentifyArg) LookupByNode(key pd2.Node) (pd2.Node, erro return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) LookupByIndex(idx int64) (pd2.Node, error) { +func (x DelegatedRouting_IdentifyArg) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { } return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x DelegatedRouting_IdentifyArg) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { } return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) MapIterator() pd2.MapIterator { +func (x DelegatedRouting_IdentifyArg) MapIterator() pd3.MapIterator { return &DelegatedRouting_IdentifyArg_MapIterator{-1, &x} } -func (x DelegatedRouting_IdentifyArg) ListIterator() pd2.ListIterator { +func (x DelegatedRouting_IdentifyArg) ListIterator() pd3.ListIterator { return nil } @@ -158,11 +160,11 @@ func (x DelegatedRouting_IdentifyArg) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) AsLink() (pd2.Link, error) { +func (x DelegatedRouting_IdentifyArg) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyArg) Prototype() pd2.NodePrototype { +func (x DelegatedRouting_IdentifyArg) Prototype() pd3.NodePrototype { return nil } @@ -170,16 +172,16 @@ func (x DelegatedRouting_IdentifyArg) Prototype() pd2.NodePrototype { type AnonList1 []pd1.String -func (v AnonList1) Node() pd2.Node { +func (v AnonList1) Node() pd3.Node { return v } -func (v *AnonList1) Parse(n pd2.Node) error { - if n.Kind() == pd2.Kind_Null { +func (v *AnonList1) Parse(n pd3.Node) error { + if n.Kind() == pd3.Kind_Null { *v = nil return nil } - if n.Kind() != pd2.Kind_List { + if n.Kind() != pd3.Kind_List { return pd1.ErrNA } else { *v = make(AnonList1, n.Length()) @@ -195,19 +197,19 @@ func (v *AnonList1) Parse(n pd2.Node) error { } } -func (AnonList1) Kind() pd2.Kind { - return pd2.Kind_List +func (AnonList1) Kind() pd3.Kind { + return pd3.Kind_List } -func (AnonList1) LookupByString(string) (pd2.Node, error) { +func (AnonList1) LookupByString(string) (pd3.Node, error) { return nil, pd1.ErrNA } -func (AnonList1) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (AnonList1) LookupByNode(key pd3.Node) (pd3.Node, error) { return nil, pd1.ErrNA } -func (v AnonList1) LookupByIndex(i int64) (pd2.Node, error) { +func (v AnonList1) LookupByIndex(i int64) (pd3.Node, error) { if i < 0 || i >= v.Length() { return nil, pd1.ErrBounds } else { @@ -215,7 +217,7 @@ func (v AnonList1) LookupByIndex(i int64) (pd2.Node, error) { } } -func (v AnonList1) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (v AnonList1) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { if i, err := seg.Index(); err != nil { return nil, pd1.ErrNA } else { @@ -223,11 +225,11 @@ func (v AnonList1) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { } } -func (AnonList1) MapIterator() pd2.MapIterator { +func (AnonList1) MapIterator() pd3.MapIterator { return nil } -func (v AnonList1) ListIterator() pd2.ListIterator { +func (v AnonList1) ListIterator() pd3.ListIterator { return &AnonList1_ListIterator{v, 0} } @@ -263,11 +265,11 @@ func (AnonList1) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (AnonList1) AsLink() (pd2.Link, error) { +func (AnonList1) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (AnonList1) Prototype() pd2.NodePrototype { +func (AnonList1) Prototype() pd3.NodePrototype { return nil // not needed } @@ -276,7 +278,7 @@ type AnonList1_ListIterator struct { at int64 } -func (iter *AnonList1_ListIterator) Next() (int64, pd2.Node, error) { +func (iter *AnonList1_ListIterator) Next() (int64, pd3.Node, error) { if iter.Done() { return -1, nil, pd1.ErrBounds } @@ -289,49 +291,50 @@ func (iter *AnonList1_ListIterator) Next() (int64, pd2.Node, error) { func (iter *AnonList1_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type DelegatedRouting_IdentifyResult -- type DelegatedRouting_IdentifyResult struct { - Methods AnonList1 + Methods AnonList1 + } -func (x DelegatedRouting_IdentifyResult) Node() pd2.Node { +func (x DelegatedRouting_IdentifyResult) Node() pd3.Node { return x } -func (x *DelegatedRouting_IdentifyResult) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *DelegatedRouting_IdentifyResult) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Methods": x.Methods.Parse, + "Methods": x.Methods.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Methods": - if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Methods") - } - if err := x.Methods.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Methods") + case "Methods": + if _, notParsed := fieldMap["Methods"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Methods") + } + if err := x.Methods.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Methods") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -343,42 +346,42 @@ type DelegatedRouting_IdentifyResult_MapIterator struct { s *DelegatedRouting_IdentifyResult } -func (x *DelegatedRouting_IdentifyResult_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *DelegatedRouting_IdentifyResult_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Methods"), x.s.Methods.Node(), nil + case 0: + return pd1.String("Methods"), x.s.Methods.Node(), nil } return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_IdentifyResult_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } -func (x DelegatedRouting_IdentifyResult) Kind() pd2.Kind { - return pd2.Kind_Map +func (x DelegatedRouting_IdentifyResult) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x DelegatedRouting_IdentifyResult) LookupByString(key string) (pd2.Node, error) { +func (x DelegatedRouting_IdentifyResult) LookupByString(key string) (pd3.Node, error) { switch key { - case "Methods": + case "Methods": return x.Methods.Node(), nil } return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x DelegatedRouting_IdentifyResult) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -388,29 +391,29 @@ func (x DelegatedRouting_IdentifyResult) LookupByNode(key pd2.Node) (pd2.Node, e return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd2.Node, error) { +func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Methods.Node(), nil } return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x DelegatedRouting_IdentifyResult) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Methods": + case "0", "Methods": return x.Methods.Node(), nil } return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) MapIterator() pd2.MapIterator { +func (x DelegatedRouting_IdentifyResult) MapIterator() pd3.MapIterator { return &DelegatedRouting_IdentifyResult_MapIterator{-1, &x} } -func (x DelegatedRouting_IdentifyResult) ListIterator() pd2.ListIterator { +func (x DelegatedRouting_IdentifyResult) ListIterator() pd3.ListIterator { return nil } @@ -446,56 +449,58 @@ func (x DelegatedRouting_IdentifyResult) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) AsLink() (pd2.Link, error) { +func (x DelegatedRouting_IdentifyResult) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x DelegatedRouting_IdentifyResult) Prototype() pd2.NodePrototype { +func (x DelegatedRouting_IdentifyResult) Prototype() pd3.NodePrototype { return nil } // -- protocol type DelegatedRouting_Error -- type DelegatedRouting_Error struct { - Code pd1.String + Code pd1.String + } -func (x DelegatedRouting_Error) Node() pd2.Node { +func (x DelegatedRouting_Error) Node() pd3.Node { return x } -func (x *DelegatedRouting_Error) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *DelegatedRouting_Error) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Code": x.Code.Parse, + "Code": x.Code.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Code": - if _, notParsed := fieldMap["Code"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Code") - } - if err := x.Code.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Code") + case "Code": + if _, notParsed := fieldMap["Code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Code") + } + if err := x.Code.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Code") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -507,42 +512,42 @@ type DelegatedRouting_Error_MapIterator struct { s *DelegatedRouting_Error } -func (x *DelegatedRouting_Error_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *DelegatedRouting_Error_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Code"), x.s.Code.Node(), nil + case 0: + return pd1.String("Code"), x.s.Code.Node(), nil } return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_Error_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } -func (x DelegatedRouting_Error) Kind() pd2.Kind { - return pd2.Kind_Map +func (x DelegatedRouting_Error) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x DelegatedRouting_Error) LookupByString(key string) (pd2.Node, error) { +func (x DelegatedRouting_Error) LookupByString(key string) (pd3.Node, error) { switch key { - case "Code": + case "Code": return x.Code.Node(), nil } return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x DelegatedRouting_Error) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -552,29 +557,29 @@ func (x DelegatedRouting_Error) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd2.Node, error) { +func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Code.Node(), nil } return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x DelegatedRouting_Error) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Code": + case "0", "Code": return x.Code.Node(), nil } return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) MapIterator() pd2.MapIterator { +func (x DelegatedRouting_Error) MapIterator() pd3.MapIterator { return &DelegatedRouting_Error_MapIterator{-1, &x} } -func (x DelegatedRouting_Error) ListIterator() pd2.ListIterator { +func (x DelegatedRouting_Error) ListIterator() pd3.ListIterator { return nil } @@ -610,24 +615,26 @@ func (x DelegatedRouting_Error) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) AsLink() (pd2.Link, error) { +func (x DelegatedRouting_Error) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x DelegatedRouting_Error) Prototype() pd2.NodePrototype { +func (x DelegatedRouting_Error) Prototype() pd3.NodePrototype { return nil } // -- protocol type AnonInductive4 -- type AnonInductive4 struct { - Identify *DelegatedRouting_IdentifyArg - GetP2PProvide *GetP2PProvideRequest + Identify *DelegatedRouting_IdentifyArg + GetP2PProvide *GetP2PProvideRequest + + } -func (x *AnonInductive4) Parse(n pd2.Node) error { +func (x *AnonInductive4) Parse(n pd3.Node) error { *x = AnonInductive4{} - if n.Kind() != pd2.Kind_Map { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() @@ -637,7 +644,7 @@ func (x *AnonInductive4) Parse(n pd2.Node) error { } k, err := kn.AsString() if err != nil { - return pd3.Errorf("inductive map key is not a string") + return pd2.Errorf("inductive map key is not a string") } switch k { case "IdentifyRequest": @@ -655,9 +662,10 @@ func (x *AnonInductive4) Parse(n pd2.Node) error { x.GetP2PProvide = &y return nil + } - return pd3.Errorf("inductive map has no applicable keys") + return pd2.Errorf("inductive map has no applicable keys") } @@ -666,19 +674,20 @@ type AnonInductive4_MapIterator struct { s *AnonInductive4 } -func (x *AnonInductive4_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *AnonInductive4_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { if x.done { return nil, nil, pd1.ErrNA } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil - case x.s.GetP2PProvide != nil: + case x.s.GetP2PProvide != nil: return pd1.String("GetP2PProvideRequest"), x.s.GetP2PProvide.Node(), nil + default: - return nil, nil, pd3.Errorf("no inductive cases are set") + return nil, nil, pd2.Errorf("no inductive cases are set") } } } @@ -687,27 +696,28 @@ func (x *AnonInductive4_MapIterator) Done() bool { return x.done } -func (x AnonInductive4) Node() pd2.Node { +func (x AnonInductive4) Node() pd3.Node { return x } -func (x AnonInductive4) Kind() pd2.Kind { - return pd2.Kind_Map +func (x AnonInductive4) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x AnonInductive4) LookupByString(key string) (pd2.Node, error) { +func (x AnonInductive4) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyRequest": + case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil - case x.GetP2PProvide != nil && key == "GetP2PProvideRequest": + case x.GetP2PProvide != nil && key == "GetP2PProvideRequest": return x.GetP2PProvide.Node(), nil + } return nil, pd1.ErrNA } -func (x AnonInductive4) LookupByNode(key pd2.Node) (pd2.Node, error) { - if key.Kind() != pd2.Kind_String { +func (x AnonInductive4) LookupByNode(key pd3.Node) (pd3.Node, error) { + if key.Kind() != pd3.Kind_String { return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { @@ -717,26 +727,27 @@ func (x AnonInductive4) LookupByNode(key pd2.Node) (pd2.Node, error) { } } -func (x AnonInductive4) LookupByIndex(idx int64) (pd2.Node, error) { +func (x AnonInductive4) LookupByIndex(idx int64) (pd3.Node, error) { return nil, pd1.ErrNA } -func (x AnonInductive4) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x AnonInductive4) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyRequest": + case "IdentifyRequest": return x.Identify.Node(), nil - case "GetP2PProvideRequest": + case "GetP2PProvideRequest": return x.GetP2PProvide.Node(), nil + } return nil, pd1.ErrNA } -func (x AnonInductive4) MapIterator() pd2.MapIterator { +func (x AnonInductive4) MapIterator() pd3.MapIterator { return &AnonInductive4_MapIterator{false, &x} } -func (x AnonInductive4) ListIterator() pd2.ListIterator { +func (x AnonInductive4) ListIterator() pd3.ListIterator { return nil } @@ -772,25 +783,26 @@ func (x AnonInductive4) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x AnonInductive4) AsLink() (pd2.Link, error) { +func (x AnonInductive4) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x AnonInductive4) Prototype() pd2.NodePrototype { +func (x AnonInductive4) Prototype() pd3.NodePrototype { return nil } - // -- protocol type AnonInductive5 -- type AnonInductive5 struct { - Identify *DelegatedRouting_IdentifyResult - GetP2PProvide *GetP2PProvideResponse - Error *DelegatedRouting_Error + Identify *DelegatedRouting_IdentifyResult + GetP2PProvide *GetP2PProvideResponse + Error *DelegatedRouting_Error + + } -func (x *AnonInductive5) Parse(n pd2.Node) error { +func (x *AnonInductive5) Parse(n pd3.Node) error { *x = AnonInductive5{} - if n.Kind() != pd2.Kind_Map { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() @@ -800,7 +812,7 @@ func (x *AnonInductive5) Parse(n pd2.Node) error { } k, err := kn.AsString() if err != nil { - return pd3.Errorf("inductive map key is not a string") + return pd2.Errorf("inductive map key is not a string") } switch k { case "IdentifyResponse": @@ -825,9 +837,10 @@ func (x *AnonInductive5) Parse(n pd2.Node) error { x.Error = &y return nil + } - return pd3.Errorf("inductive map has no applicable keys") + return pd2.Errorf("inductive map has no applicable keys") } @@ -836,21 +849,22 @@ type AnonInductive5_MapIterator struct { s *AnonInductive5 } -func (x *AnonInductive5_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *AnonInductive5_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { if x.done { return nil, nil, pd1.ErrNA } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil - case x.s.GetP2PProvide != nil: + case x.s.GetP2PProvide != nil: return pd1.String("GetP2PProvideResponse"), x.s.GetP2PProvide.Node(), nil - case x.s.Error != nil: + case x.s.Error != nil: return pd1.String("Error"), x.s.Error.Node(), nil + default: - return nil, nil, pd3.Errorf("no inductive cases are set") + return nil, nil, pd2.Errorf("no inductive cases are set") } } } @@ -859,29 +873,30 @@ func (x *AnonInductive5_MapIterator) Done() bool { return x.done } -func (x AnonInductive5) Node() pd2.Node { +func (x AnonInductive5) Node() pd3.Node { return x } -func (x AnonInductive5) Kind() pd2.Kind { - return pd2.Kind_Map +func (x AnonInductive5) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x AnonInductive5) LookupByString(key string) (pd2.Node, error) { +func (x AnonInductive5) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyResponse": + case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil - case x.GetP2PProvide != nil && key == "GetP2PProvideResponse": + case x.GetP2PProvide != nil && key == "GetP2PProvideResponse": return x.GetP2PProvide.Node(), nil - case x.Error != nil && key == "Error": + case x.Error != nil && key == "Error": return x.Error.Node(), nil + } return nil, pd1.ErrNA } -func (x AnonInductive5) LookupByNode(key pd2.Node) (pd2.Node, error) { - if key.Kind() != pd2.Kind_String { +func (x AnonInductive5) LookupByNode(key pd3.Node) (pd3.Node, error) { + if key.Kind() != pd3.Kind_String { return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { @@ -891,28 +906,29 @@ func (x AnonInductive5) LookupByNode(key pd2.Node) (pd2.Node, error) { } } -func (x AnonInductive5) LookupByIndex(idx int64) (pd2.Node, error) { +func (x AnonInductive5) LookupByIndex(idx int64) (pd3.Node, error) { return nil, pd1.ErrNA } -func (x AnonInductive5) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x AnonInductive5) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyResponse": + case "IdentifyResponse": return x.Identify.Node(), nil - case "GetP2PProvideResponse": + case "GetP2PProvideResponse": return x.GetP2PProvide.Node(), nil - case "Error": + case "Error": return x.Error.Node(), nil + } return nil, pd1.ErrNA } -func (x AnonInductive5) MapIterator() pd2.MapIterator { +func (x AnonInductive5) MapIterator() pd3.MapIterator { return &AnonInductive5_MapIterator{false, &x} } -func (x AnonInductive5) ListIterator() pd2.ListIterator { +func (x AnonInductive5) ListIterator() pd3.ListIterator { return nil } @@ -948,26 +964,29 @@ func (x AnonInductive5) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x AnonInductive5) AsLink() (pd2.Link, error) { +func (x AnonInductive5) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x AnonInductive5) Prototype() pd2.NodePrototype { +func (x AnonInductive5) Prototype() pd3.NodePrototype { return nil } - -var logger_client_DelegatedRouting = pd4.Logger("service/client/delegatedrouting") +var logger_client_DelegatedRouting = pd5.Logger("service/client/delegatedrouting") type DelegatedRouting_Client interface { - Identify(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) - GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) +Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) + +GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) + - Identify_Async(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) +Identify_Async(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) + +GetP2PProvide_Async(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) - GetP2PProvide_Async(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) } + type DelegatedRouting_Identify_AsyncResult struct { Resp *DelegatedRouting_IdentifyResult Err error @@ -978,16 +997,17 @@ type DelegatedRouting_GetP2PProvide_AsyncResult struct { Err error } + type DelegatedRouting_ClientOption func(*client_DelegatedRouting) error type client_DelegatedRouting struct { - httpClient *pd12.Client - endpoint *pd10.URL - ulk pd14.Mutex + httpClient *pd4.Client + endpoint *pd12.URL + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } -func DelegatedRouting_Client_WithHTTPClient(hc *pd12.Client) DelegatedRouting_ClientOption { +func DelegatedRouting_Client_WithHTTPClient(hc *pd4.Client) DelegatedRouting_ClientOption { return func(c *client_DelegatedRouting) error { c.httpClient = hc return nil @@ -995,11 +1015,11 @@ func DelegatedRouting_Client_WithHTTPClient(hc *pd12.Client) DelegatedRouting_Cl } func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_ClientOption) (*client_DelegatedRouting, error) { - u, err := pd10.Parse(endpoint) + u, err := pd12.Parse(endpoint) if err != nil { return nil, err } - c := &client_DelegatedRouting{endpoint: u, httpClient: pd12.DefaultClient, unsupported: make(map[string]bool)} + c := &client_DelegatedRouting{endpoint: u, httpClient: pd4.DefaultClient, unsupported: make(map[string]bool)} for _, o := range opts { if err := o(c); err != nil { return nil, err @@ -1008,8 +1028,10 @@ func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_Clien return c, nil } -func (c *client_DelegatedRouting) Identify(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { - ctx, cancel := pd8.WithCancel(ctx) + + +func (c *client_DelegatedRouting) Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { + ctx, cancel := pd7.WithCancel(ctx) defer cancel() ch, err := c.Identify_Async(ctx, req) if err != nil { @@ -1037,7 +1059,7 @@ func (c *client_DelegatedRouting) Identify(ctx pd8.Context, req *DelegatedRoutin } } -func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) { +func (c *client_DelegatedRouting) Identify_Async(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["Identify"] @@ -1050,14 +1072,14 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *Delegated Identify: req, } - buf, err := pd9.Encode(envelope, pd5.Encode) + buf, err := pd11.Encode(envelope, pd8.Encode) if err != nil { - return nil, pd3.Errorf("unexpected serialization error (%v)", err) + return nil, pd2.Errorf("serializing DAG-JSON request: %w", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd12.NewRequestWithContext(ctx, "POST", u.String(), pd6.NewReader(buf)) + httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd6.NewReader(buf)) if err != nil { return nil, err } @@ -1069,7 +1091,7 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *Delegated resp, err := c.httpClient.Do(httpReq) if err != nil { - return nil, pd3.Errorf("sending HTTP request: %w", err) + return nil, pd2.Errorf("sending HTTP request: %w", err) } // HTTP codes 400 and 404 correspond to unrecognized method or request schema @@ -1087,12 +1109,12 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *Delegated resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd13.ErrService{Cause: pd2.Errorf("%s", errValues[0])} } else { - err = pd3.Errorf("service rejected the call, no cause provided") + err = pd2.Errorf("service rejected the call, no cause provided") } } else { - err = pd3.Errorf("service rejected the call") + err = pd2.Errorf("service rejected the call") } return nil, err } @@ -1102,20 +1124,20 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *Delegated return ch, nil } -func process_DelegatedRouting_Identify_AsyncResult(ctx pd8.Context, ch chan<- DelegatedRouting_Identify_AsyncResult, r pd7.ReadCloser) { +func process_DelegatedRouting_Identify_AsyncResult(ctx pd7.Context, ch chan<- DelegatedRouting_Identify_AsyncResult, r pd10.ReadCloser) { defer close(ch) defer r.Close() - opt := pd5.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + opt := pd8.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { var out DelegatedRouting_Identify_AsyncResult - n, err := pd9.DecodeStreaming(r, opt.Decode) + n, err := pd11.DecodeStreaming(r, opt.Decode) - if pd11.Is(err, pd7.EOF) || pd11.Is(err, pd7.ErrUnexpectedEOF) || pd11.Is(err, pd8.DeadlineExceeded) || pd11.Is(err, pd8.Canceled) { + if pd9.Is(err, pd10.EOF) || pd9.Is(err, pd10.ErrUnexpectedEOF) || pd9.Is(err, pd7.DeadlineExceeded) || pd9.Is(err, pd7.Canceled) { return } @@ -1124,13 +1146,13 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd8.Context, ch chan<- De } else { var x [1]byte if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { - out = DelegatedRouting_Identify_AsyncResult{Err: pd13.ErrProto{Cause: pd3.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error + out = DelegatedRouting_Identify_AsyncResult{Err: pd13.ErrProto{Cause: pd2.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { env := &AnonInductive5{} if err = env.Parse(n); err != nil { out = DelegatedRouting_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error } else if env.Error != nil { - out = DelegatedRouting_Identify_AsyncResult{Err: pd13.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error + out = DelegatedRouting_Identify_AsyncResult{Err: pd13.ErrService{Cause: pd9.New(string(env.Error.Code))}} // service-level error } else if env.Identify != nil { out = DelegatedRouting_Identify_AsyncResult{Resp: env.Identify} } else { @@ -1140,15 +1162,16 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd8.Context, ch chan<- De } select { - case <-ctx.Done(): - return - case ch <- out: + case <- ctx.Done(): + return + case ch <- out: } } } -func (c *client_DelegatedRouting) GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { - ctx, cancel := pd8.WithCancel(ctx) + +func (c *client_DelegatedRouting) GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { + ctx, cancel := pd7.WithCancel(ctx) defer cancel() ch, err := c.GetP2PProvide_Async(ctx, req) if err != nil { @@ -1176,7 +1199,7 @@ func (c *client_DelegatedRouting) GetP2PProvide(ctx pd8.Context, req *GetP2PProv } } -func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) { +func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["GetP2PProvide"] @@ -1189,14 +1212,14 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP GetP2PProvide: req, } - buf, err := pd9.Encode(envelope, pd5.Encode) + buf, err := pd11.Encode(envelope, pd8.Encode) if err != nil { - return nil, pd3.Errorf("unexpected serialization error (%v)", err) + return nil, pd2.Errorf("serializing DAG-JSON request: %w", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd12.NewRequestWithContext(ctx, "POST", u.String(), pd6.NewReader(buf)) + httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd6.NewReader(buf)) if err != nil { return nil, err } @@ -1208,7 +1231,7 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP resp, err := c.httpClient.Do(httpReq) if err != nil { - return nil, pd3.Errorf("sending HTTP request: %w", err) + return nil, pd2.Errorf("sending HTTP request: %w", err) } // HTTP codes 400 and 404 correspond to unrecognized method or request schema @@ -1226,12 +1249,12 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd13.ErrService{Cause: pd2.Errorf("%s", errValues[0])} } else { - err = pd3.Errorf("service rejected the call, no cause provided") + err = pd2.Errorf("service rejected the call, no cause provided") } } else { - err = pd3.Errorf("service rejected the call") + err = pd2.Errorf("service rejected the call") } return nil, err } @@ -1241,20 +1264,20 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP return ch, nil } -func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd8.Context, ch chan<- DelegatedRouting_GetP2PProvide_AsyncResult, r pd7.ReadCloser) { +func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd7.Context, ch chan<- DelegatedRouting_GetP2PProvide_AsyncResult, r pd10.ReadCloser) { defer close(ch) defer r.Close() - opt := pd5.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + opt := pd8.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { var out DelegatedRouting_GetP2PProvide_AsyncResult - n, err := pd9.DecodeStreaming(r, opt.Decode) + n, err := pd11.DecodeStreaming(r, opt.Decode) - if pd11.Is(err, pd7.EOF) || pd11.Is(err, pd7.ErrUnexpectedEOF) || pd11.Is(err, pd8.DeadlineExceeded) || pd11.Is(err, pd8.Canceled) { + if pd9.Is(err, pd10.EOF) || pd9.Is(err, pd10.ErrUnexpectedEOF) || pd9.Is(err, pd7.DeadlineExceeded) || pd9.Is(err, pd7.Canceled) { return } @@ -1263,13 +1286,13 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd8.Context, ch chan } else { var x [1]byte if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { - out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd13.ErrProto{Cause: pd3.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error + out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd13.ErrProto{Cause: pd2.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { env := &AnonInductive5{} if err = env.Parse(n); err != nil { out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error } else if env.Error != nil { - out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd13.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error + out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd13.ErrService{Cause: pd9.New(string(env.Error.Code))}} // service-level error } else if env.GetP2PProvide != nil { out = DelegatedRouting_GetP2PProvide_AsyncResult{Resp: env.GetP2PProvide} } else { @@ -1279,29 +1302,31 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd8.Context, ch chan } select { - case <-ctx.Done(): - return - case ch <- out: + case <- ctx.Done(): + return + case ch <- out: } } } -var logger_server_DelegatedRouting = pd4.Logger("service/server/delegatedrouting") + +var logger_server_DelegatedRouting = pd5.Logger("service/server/delegatedrouting") type DelegatedRouting_Server interface { - GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) + + GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) } -func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd12.HandlerFunc { - return func(writer pd12.ResponseWriter, request *pd12.Request) { +func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { + return func(writer pd4.ResponseWriter, request *pd4.Request) { // parse request - msg, err := pd15.ReadAll(request.Body) + msg, err := pd10.ReadAll(request.Body) if err != nil { logger_server_DelegatedRouting.Errorf("reading request body (%v)", err) writer.WriteHeader(400) return } - n, err := pd9.Decode(msg, pd5.Decode) + n, err := pd11.Decode(msg, pd8.Decode) if err != nil { logger_server_DelegatedRouting.Errorf("received request not decodeable (%v)", err) writer.WriteHeader(400) @@ -1331,7 +1356,7 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd12.HandlerFunc { } writer.WriteHeader(200) - if f, ok := writer.(pd12.Flusher); ok { + if f, ok := writer.(pd4.Flusher); ok { f.Flush() } @@ -1345,34 +1370,36 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd12.HandlerFunc { } var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())}} + env = &AnonInductive5{ Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())} } } else { - env = &AnonInductive5{GetP2PProvide: resp.Resp} + env = &AnonInductive5{ GetP2PProvide: resp.Resp } } var buf pd6.Buffer - if err = pd9.EncodeStreaming(&buf, env, pd5.Encode); err != nil { + if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode response (%v)", err) continue } buf.WriteByte("\n"[0]) writer.Write(buf.Bytes()) - if f, ok := writer.(pd12.Flusher); ok { + if f, ok := writer.(pd4.Flusher); ok { f.Flush() } } } + case env.Identify != nil: var env *AnonInductive5 env = &AnonInductive5{ Identify: &DelegatedRouting_IdentifyResult{ Methods: []pd1.String{ "GetP2PProvide", + }, }, } var buf pd6.Buffer - if err = pd9.EncodeStreaming(&buf, env, pd5.Encode); err != nil { + if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode identify response (%v)", err) writer.WriteHeader(500) return @@ -1391,16 +1418,16 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd12.HandlerFunc { type AnonList7 []Multihash -func (v AnonList7) Node() pd2.Node { +func (v AnonList7) Node() pd3.Node { return v } -func (v *AnonList7) Parse(n pd2.Node) error { - if n.Kind() == pd2.Kind_Null { +func (v *AnonList7) Parse(n pd3.Node) error { + if n.Kind() == pd3.Kind_Null { *v = nil return nil } - if n.Kind() != pd2.Kind_List { + if n.Kind() != pd3.Kind_List { return pd1.ErrNA } else { *v = make(AnonList7, n.Length()) @@ -1416,19 +1443,19 @@ func (v *AnonList7) Parse(n pd2.Node) error { } } -func (AnonList7) Kind() pd2.Kind { - return pd2.Kind_List +func (AnonList7) Kind() pd3.Kind { + return pd3.Kind_List } -func (AnonList7) LookupByString(string) (pd2.Node, error) { +func (AnonList7) LookupByString(string) (pd3.Node, error) { return nil, pd1.ErrNA } -func (AnonList7) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (AnonList7) LookupByNode(key pd3.Node) (pd3.Node, error) { return nil, pd1.ErrNA } -func (v AnonList7) LookupByIndex(i int64) (pd2.Node, error) { +func (v AnonList7) LookupByIndex(i int64) (pd3.Node, error) { if i < 0 || i >= v.Length() { return nil, pd1.ErrBounds } else { @@ -1436,7 +1463,7 @@ func (v AnonList7) LookupByIndex(i int64) (pd2.Node, error) { } } -func (v AnonList7) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (v AnonList7) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { if i, err := seg.Index(); err != nil { return nil, pd1.ErrNA } else { @@ -1444,11 +1471,11 @@ func (v AnonList7) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { } } -func (AnonList7) MapIterator() pd2.MapIterator { +func (AnonList7) MapIterator() pd3.MapIterator { return nil } -func (v AnonList7) ListIterator() pd2.ListIterator { +func (v AnonList7) ListIterator() pd3.ListIterator { return &AnonList7_ListIterator{v, 0} } @@ -1484,11 +1511,11 @@ func (AnonList7) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (AnonList7) AsLink() (pd2.Link, error) { +func (AnonList7) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (AnonList7) Prototype() pd2.NodePrototype { +func (AnonList7) Prototype() pd3.NodePrototype { return nil // not needed } @@ -1497,7 +1524,7 @@ type AnonList7_ListIterator struct { at int64 } -func (iter *AnonList7_ListIterator) Next() (int64, pd2.Node, error) { +func (iter *AnonList7_ListIterator) Next() (int64, pd3.Node, error) { if iter.Done() { return -1, nil, pd1.ErrBounds } @@ -1510,49 +1537,50 @@ func (iter *AnonList7_ListIterator) Next() (int64, pd2.Node, error) { func (iter *AnonList7_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type GetP2PProvideRequest -- type GetP2PProvideRequest struct { - Keys AnonList7 + Keys AnonList7 + } -func (x GetP2PProvideRequest) Node() pd2.Node { +func (x GetP2PProvideRequest) Node() pd3.Node { return x } -func (x *GetP2PProvideRequest) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *GetP2PProvideRequest) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Keys": x.Keys.Parse, + "Keys": x.Keys.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Keys": - if _, notParsed := fieldMap["Keys"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Keys") - } - if err := x.Keys.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Keys") + case "Keys": + if _, notParsed := fieldMap["Keys"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Keys") + } + if err := x.Keys.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Keys") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -1564,42 +1592,42 @@ type GetP2PProvideRequest_MapIterator struct { s *GetP2PProvideRequest } -func (x *GetP2PProvideRequest_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *GetP2PProvideRequest_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Keys"), x.s.Keys.Node(), nil + case 0: + return pd1.String("Keys"), x.s.Keys.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GetP2PProvideRequest_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } -func (x GetP2PProvideRequest) Kind() pd2.Kind { - return pd2.Kind_Map +func (x GetP2PProvideRequest) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x GetP2PProvideRequest) LookupByString(key string) (pd2.Node, error) { +func (x GetP2PProvideRequest) LookupByString(key string) (pd3.Node, error) { switch key { - case "Keys": + case "Keys": return x.Keys.Node(), nil } return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x GetP2PProvideRequest) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -1609,29 +1637,29 @@ func (x GetP2PProvideRequest) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd2.Node, error) { +func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Keys.Node(), nil } return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x GetP2PProvideRequest) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Keys": + case "0", "Keys": return x.Keys.Node(), nil } return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) MapIterator() pd2.MapIterator { +func (x GetP2PProvideRequest) MapIterator() pd3.MapIterator { return &GetP2PProvideRequest_MapIterator{-1, &x} } -func (x GetP2PProvideRequest) ListIterator() pd2.ListIterator { +func (x GetP2PProvideRequest) ListIterator() pd3.ListIterator { return nil } @@ -1667,11 +1695,11 @@ func (x GetP2PProvideRequest) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) AsLink() (pd2.Link, error) { +func (x GetP2PProvideRequest) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x GetP2PProvideRequest) Prototype() pd2.NodePrototype { +func (x GetP2PProvideRequest) Prototype() pd3.NodePrototype { return nil } @@ -1679,16 +1707,16 @@ func (x GetP2PProvideRequest) Prototype() pd2.NodePrototype { type AnonList9 []ProvidersByKey -func (v AnonList9) Node() pd2.Node { +func (v AnonList9) Node() pd3.Node { return v } -func (v *AnonList9) Parse(n pd2.Node) error { - if n.Kind() == pd2.Kind_Null { +func (v *AnonList9) Parse(n pd3.Node) error { + if n.Kind() == pd3.Kind_Null { *v = nil return nil } - if n.Kind() != pd2.Kind_List { + if n.Kind() != pd3.Kind_List { return pd1.ErrNA } else { *v = make(AnonList9, n.Length()) @@ -1704,19 +1732,19 @@ func (v *AnonList9) Parse(n pd2.Node) error { } } -func (AnonList9) Kind() pd2.Kind { - return pd2.Kind_List +func (AnonList9) Kind() pd3.Kind { + return pd3.Kind_List } -func (AnonList9) LookupByString(string) (pd2.Node, error) { +func (AnonList9) LookupByString(string) (pd3.Node, error) { return nil, pd1.ErrNA } -func (AnonList9) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (AnonList9) LookupByNode(key pd3.Node) (pd3.Node, error) { return nil, pd1.ErrNA } -func (v AnonList9) LookupByIndex(i int64) (pd2.Node, error) { +func (v AnonList9) LookupByIndex(i int64) (pd3.Node, error) { if i < 0 || i >= v.Length() { return nil, pd1.ErrBounds } else { @@ -1724,7 +1752,7 @@ func (v AnonList9) LookupByIndex(i int64) (pd2.Node, error) { } } -func (v AnonList9) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (v AnonList9) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { if i, err := seg.Index(); err != nil { return nil, pd1.ErrNA } else { @@ -1732,11 +1760,11 @@ func (v AnonList9) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { } } -func (AnonList9) MapIterator() pd2.MapIterator { +func (AnonList9) MapIterator() pd3.MapIterator { return nil } -func (v AnonList9) ListIterator() pd2.ListIterator { +func (v AnonList9) ListIterator() pd3.ListIterator { return &AnonList9_ListIterator{v, 0} } @@ -1772,11 +1800,11 @@ func (AnonList9) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (AnonList9) AsLink() (pd2.Link, error) { +func (AnonList9) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (AnonList9) Prototype() pd2.NodePrototype { +func (AnonList9) Prototype() pd3.NodePrototype { return nil // not needed } @@ -1785,7 +1813,7 @@ type AnonList9_ListIterator struct { at int64 } -func (iter *AnonList9_ListIterator) Next() (int64, pd2.Node, error) { +func (iter *AnonList9_ListIterator) Next() (int64, pd3.Node, error) { if iter.Done() { return -1, nil, pd1.ErrBounds } @@ -1798,49 +1826,50 @@ func (iter *AnonList9_ListIterator) Next() (int64, pd2.Node, error) { func (iter *AnonList9_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type GetP2PProvideResponse -- type GetP2PProvideResponse struct { - ProvidersByKey AnonList9 + ProvidersByKey AnonList9 + } -func (x GetP2PProvideResponse) Node() pd2.Node { +func (x GetP2PProvideResponse) Node() pd3.Node { return x } -func (x *GetP2PProvideResponse) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *GetP2PProvideResponse) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "ProvidersByKey": x.ProvidersByKey.Parse, + "ProvidersByKey": x.ProvidersByKey.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "ProvidersByKey": - if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { - return pd3.Errorf("field %s already parsed", "ProvidersByKey") - } - if err := x.ProvidersByKey.Parse(vn); err != nil { - return err - } - delete(fieldMap, "ProvidersByKey") + case "ProvidersByKey": + if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { + return pd2.Errorf("field %s already parsed", "ProvidersByKey") + } + if err := x.ProvidersByKey.Parse(vn); err != nil { + return err + } + delete(fieldMap, "ProvidersByKey") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -1852,42 +1881,42 @@ type GetP2PProvideResponse_MapIterator struct { s *GetP2PProvideResponse } -func (x *GetP2PProvideResponse_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *GetP2PProvideResponse_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil + case 0: + return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GetP2PProvideResponse_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } -func (x GetP2PProvideResponse) Kind() pd2.Kind { - return pd2.Kind_Map +func (x GetP2PProvideResponse) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x GetP2PProvideResponse) LookupByString(key string) (pd2.Node, error) { +func (x GetP2PProvideResponse) LookupByString(key string) (pd3.Node, error) { switch key { - case "ProvidersByKey": + case "ProvidersByKey": return x.ProvidersByKey.Node(), nil } return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x GetP2PProvideResponse) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -1897,29 +1926,29 @@ func (x GetP2PProvideResponse) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd2.Node, error) { +func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.ProvidersByKey.Node(), nil } return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x GetP2PProvideResponse) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "ProvidersByKey": + case "0", "ProvidersByKey": return x.ProvidersByKey.Node(), nil } return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) MapIterator() pd2.MapIterator { +func (x GetP2PProvideResponse) MapIterator() pd3.MapIterator { return &GetP2PProvideResponse_MapIterator{-1, &x} } -func (x GetP2PProvideResponse) ListIterator() pd2.ListIterator { +func (x GetP2PProvideResponse) ListIterator() pd3.ListIterator { return nil } @@ -1955,66 +1984,68 @@ func (x GetP2PProvideResponse) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) AsLink() (pd2.Link, error) { +func (x GetP2PProvideResponse) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x GetP2PProvideResponse) Prototype() pd2.NodePrototype { +func (x GetP2PProvideResponse) Prototype() pd3.NodePrototype { return nil } // -- protocol type ProvidersByKey -- type ProvidersByKey struct { - Key Multihash - Provider Provider + Key Multihash + Provider Provider + } -func (x ProvidersByKey) Node() pd2.Node { +func (x ProvidersByKey) Node() pd3.Node { return x } -func (x *ProvidersByKey) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *ProvidersByKey) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Key": x.Key.Parse, + "Key": x.Key.Parse, "Provider": x.Provider.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Key": - if _, notParsed := fieldMap["Key"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Key") - } - if err := x.Key.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Key") - case "Provider": - if _, notParsed := fieldMap["Provider"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Provider") - } - if err := x.Provider.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Provider") + case "Key": + if _, notParsed := fieldMap["Key"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Key") + } + if err := x.Key.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Key") + case "Provider": + if _, notParsed := fieldMap["Provider"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Provider") + } + if err := x.Provider.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Provider") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -2026,46 +2057,46 @@ type ProvidersByKey_MapIterator struct { s *ProvidersByKey } -func (x *ProvidersByKey_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *ProvidersByKey_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Key"), x.s.Key.Node(), nil - case 1: - return pd1.String("Provider"), x.s.Provider.Node(), nil + case 0: + return pd1.String("Key"), x.s.Key.Node(), nil + case 1: + return pd1.String("Provider"), x.s.Provider.Node(), nil } return nil, nil, pd1.ErrNA } func (x *ProvidersByKey_MapIterator) Done() bool { - return x.i+1 >= 2 + return x.i + 1 >= 2 } -func (x ProvidersByKey) Kind() pd2.Kind { - return pd2.Kind_Map +func (x ProvidersByKey) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x ProvidersByKey) LookupByString(key string) (pd2.Node, error) { +func (x ProvidersByKey) LookupByString(key string) (pd3.Node, error) { switch key { - case "Key": + case "Key": return x.Key.Node(), nil - case "Provider": + case "Provider": return x.Provider.Node(), nil } return nil, pd1.ErrNA } -func (x ProvidersByKey) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x ProvidersByKey) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -2075,33 +2106,33 @@ func (x ProvidersByKey) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd1.ErrNA } -func (x ProvidersByKey) LookupByIndex(idx int64) (pd2.Node, error) { +func (x ProvidersByKey) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Key.Node(), nil - case 1: + case 1: return x.Provider.Node(), nil } return nil, pd1.ErrNA } -func (x ProvidersByKey) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x ProvidersByKey) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Key": + case "0", "Key": return x.Key.Node(), nil - case "1", "Provider": + case "1", "Provider": return x.Provider.Node(), nil } return nil, pd1.ErrNA } -func (x ProvidersByKey) MapIterator() pd2.MapIterator { +func (x ProvidersByKey) MapIterator() pd3.MapIterator { return &ProvidersByKey_MapIterator{-1, &x} } -func (x ProvidersByKey) ListIterator() pd2.ListIterator { +func (x ProvidersByKey) ListIterator() pd3.ListIterator { return nil } @@ -2137,56 +2168,58 @@ func (x ProvidersByKey) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x ProvidersByKey) AsLink() (pd2.Link, error) { +func (x ProvidersByKey) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x ProvidersByKey) Prototype() pd2.NodePrototype { +func (x ProvidersByKey) Prototype() pd3.NodePrototype { return nil } // -- protocol type Multihash -- type Multihash struct { - Bytes pd1.Bytes + Bytes pd1.Bytes + } -func (x Multihash) Node() pd2.Node { +func (x Multihash) Node() pd3.Node { return x } -func (x *Multihash) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *Multihash) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Bytes": x.Bytes.Parse, + "Bytes": x.Bytes.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Bytes": - if _, notParsed := fieldMap["Bytes"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Bytes") - } - if err := x.Bytes.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Bytes") + case "Bytes": + if _, notParsed := fieldMap["Bytes"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Bytes") + } + if err := x.Bytes.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Bytes") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -2198,42 +2231,42 @@ type Multihash_MapIterator struct { s *Multihash } -func (x *Multihash_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *Multihash_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Bytes"), x.s.Bytes.Node(), nil + case 0: + return pd1.String("Bytes"), x.s.Bytes.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Multihash_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } -func (x Multihash) Kind() pd2.Kind { - return pd2.Kind_Map +func (x Multihash) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x Multihash) LookupByString(key string) (pd2.Node, error) { +func (x Multihash) LookupByString(key string) (pd3.Node, error) { switch key { - case "Bytes": + case "Bytes": return x.Bytes.Node(), nil } return nil, pd1.ErrNA } -func (x Multihash) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x Multihash) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -2243,29 +2276,29 @@ func (x Multihash) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd1.ErrNA } -func (x Multihash) LookupByIndex(idx int64) (pd2.Node, error) { +func (x Multihash) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Bytes.Node(), nil } return nil, pd1.ErrNA } -func (x Multihash) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x Multihash) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Bytes": + case "0", "Bytes": return x.Bytes.Node(), nil } return nil, pd1.ErrNA } -func (x Multihash) MapIterator() pd2.MapIterator { +func (x Multihash) MapIterator() pd3.MapIterator { return &Multihash_MapIterator{-1, &x} } -func (x Multihash) ListIterator() pd2.ListIterator { +func (x Multihash) ListIterator() pd3.ListIterator { return nil } @@ -2301,11 +2334,11 @@ func (x Multihash) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x Multihash) AsLink() (pd2.Link, error) { +func (x Multihash) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x Multihash) Prototype() pd2.NodePrototype { +func (x Multihash) Prototype() pd3.NodePrototype { return nil } @@ -2313,16 +2346,16 @@ func (x Multihash) Prototype() pd2.NodePrototype { type AnonList13 []Node -func (v AnonList13) Node() pd2.Node { +func (v AnonList13) Node() pd3.Node { return v } -func (v *AnonList13) Parse(n pd2.Node) error { - if n.Kind() == pd2.Kind_Null { +func (v *AnonList13) Parse(n pd3.Node) error { + if n.Kind() == pd3.Kind_Null { *v = nil return nil } - if n.Kind() != pd2.Kind_List { + if n.Kind() != pd3.Kind_List { return pd1.ErrNA } else { *v = make(AnonList13, n.Length()) @@ -2338,19 +2371,19 @@ func (v *AnonList13) Parse(n pd2.Node) error { } } -func (AnonList13) Kind() pd2.Kind { - return pd2.Kind_List +func (AnonList13) Kind() pd3.Kind { + return pd3.Kind_List } -func (AnonList13) LookupByString(string) (pd2.Node, error) { +func (AnonList13) LookupByString(string) (pd3.Node, error) { return nil, pd1.ErrNA } -func (AnonList13) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (AnonList13) LookupByNode(key pd3.Node) (pd3.Node, error) { return nil, pd1.ErrNA } -func (v AnonList13) LookupByIndex(i int64) (pd2.Node, error) { +func (v AnonList13) LookupByIndex(i int64) (pd3.Node, error) { if i < 0 || i >= v.Length() { return nil, pd1.ErrBounds } else { @@ -2358,7 +2391,7 @@ func (v AnonList13) LookupByIndex(i int64) (pd2.Node, error) { } } -func (v AnonList13) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (v AnonList13) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { if i, err := seg.Index(); err != nil { return nil, pd1.ErrNA } else { @@ -2366,11 +2399,11 @@ func (v AnonList13) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { } } -func (AnonList13) MapIterator() pd2.MapIterator { +func (AnonList13) MapIterator() pd3.MapIterator { return nil } -func (v AnonList13) ListIterator() pd2.ListIterator { +func (v AnonList13) ListIterator() pd3.ListIterator { return &AnonList13_ListIterator{v, 0} } @@ -2406,11 +2439,11 @@ func (AnonList13) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (AnonList13) AsLink() (pd2.Link, error) { +func (AnonList13) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (AnonList13) Prototype() pd2.NodePrototype { +func (AnonList13) Prototype() pd3.NodePrototype { return nil // not needed } @@ -2419,7 +2452,7 @@ type AnonList13_ListIterator struct { at int64 } -func (iter *AnonList13_ListIterator) Next() (int64, pd2.Node, error) { +func (iter *AnonList13_ListIterator) Next() (int64, pd3.Node, error) { if iter.Done() { return -1, nil, pd1.ErrBounds } @@ -2432,21 +2465,20 @@ func (iter *AnonList13_ListIterator) Next() (int64, pd2.Node, error) { func (iter *AnonList13_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type AnonList14 -- type AnonList14 []TransferProto -func (v AnonList14) Node() pd2.Node { +func (v AnonList14) Node() pd3.Node { return v } -func (v *AnonList14) Parse(n pd2.Node) error { - if n.Kind() == pd2.Kind_Null { +func (v *AnonList14) Parse(n pd3.Node) error { + if n.Kind() == pd3.Kind_Null { *v = nil return nil } - if n.Kind() != pd2.Kind_List { + if n.Kind() != pd3.Kind_List { return pd1.ErrNA } else { *v = make(AnonList14, n.Length()) @@ -2462,19 +2494,19 @@ func (v *AnonList14) Parse(n pd2.Node) error { } } -func (AnonList14) Kind() pd2.Kind { - return pd2.Kind_List +func (AnonList14) Kind() pd3.Kind { + return pd3.Kind_List } -func (AnonList14) LookupByString(string) (pd2.Node, error) { +func (AnonList14) LookupByString(string) (pd3.Node, error) { return nil, pd1.ErrNA } -func (AnonList14) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (AnonList14) LookupByNode(key pd3.Node) (pd3.Node, error) { return nil, pd1.ErrNA } -func (v AnonList14) LookupByIndex(i int64) (pd2.Node, error) { +func (v AnonList14) LookupByIndex(i int64) (pd3.Node, error) { if i < 0 || i >= v.Length() { return nil, pd1.ErrBounds } else { @@ -2482,7 +2514,7 @@ func (v AnonList14) LookupByIndex(i int64) (pd2.Node, error) { } } -func (v AnonList14) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (v AnonList14) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { if i, err := seg.Index(); err != nil { return nil, pd1.ErrNA } else { @@ -2490,11 +2522,11 @@ func (v AnonList14) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { } } -func (AnonList14) MapIterator() pd2.MapIterator { +func (AnonList14) MapIterator() pd3.MapIterator { return nil } -func (v AnonList14) ListIterator() pd2.ListIterator { +func (v AnonList14) ListIterator() pd3.ListIterator { return &AnonList14_ListIterator{v, 0} } @@ -2530,11 +2562,11 @@ func (AnonList14) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (AnonList14) AsLink() (pd2.Link, error) { +func (AnonList14) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (AnonList14) Prototype() pd2.NodePrototype { +func (AnonList14) Prototype() pd3.NodePrototype { return nil // not needed } @@ -2543,7 +2575,7 @@ type AnonList14_ListIterator struct { at int64 } -func (iter *AnonList14_ListIterator) Next() (int64, pd2.Node, error) { +func (iter *AnonList14_ListIterator) Next() (int64, pd3.Node, error) { if iter.Done() { return -1, nil, pd1.ErrBounds } @@ -2556,59 +2588,60 @@ func (iter *AnonList14_ListIterator) Next() (int64, pd2.Node, error) { func (iter *AnonList14_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type Provider -- type Provider struct { - Nodes AnonList13 - Proto AnonList14 + Nodes AnonList13 + Proto AnonList14 + } -func (x Provider) Node() pd2.Node { +func (x Provider) Node() pd3.Node { return x } -func (x *Provider) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *Provider) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Nodes": x.Nodes.Parse, + "Nodes": x.Nodes.Parse, "Proto": x.Proto.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Nodes": - if _, notParsed := fieldMap["Nodes"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Nodes") - } - if err := x.Nodes.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Nodes") - case "Proto": - if _, notParsed := fieldMap["Proto"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Proto") - } - if err := x.Proto.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Proto") + case "Nodes": + if _, notParsed := fieldMap["Nodes"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Nodes") + } + if err := x.Nodes.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Nodes") + case "Proto": + if _, notParsed := fieldMap["Proto"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Proto") + } + if err := x.Proto.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Proto") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -2620,46 +2653,46 @@ type Provider_MapIterator struct { s *Provider } -func (x *Provider_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *Provider_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Nodes"), x.s.Nodes.Node(), nil - case 1: - return pd1.String("Proto"), x.s.Proto.Node(), nil + case 0: + return pd1.String("Nodes"), x.s.Nodes.Node(), nil + case 1: + return pd1.String("Proto"), x.s.Proto.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Provider_MapIterator) Done() bool { - return x.i+1 >= 2 + return x.i + 1 >= 2 } -func (x Provider) Kind() pd2.Kind { - return pd2.Kind_Map +func (x Provider) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x Provider) LookupByString(key string) (pd2.Node, error) { +func (x Provider) LookupByString(key string) (pd3.Node, error) { switch key { - case "Nodes": + case "Nodes": return x.Nodes.Node(), nil - case "Proto": + case "Proto": return x.Proto.Node(), nil } return nil, pd1.ErrNA } -func (x Provider) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x Provider) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -2669,33 +2702,33 @@ func (x Provider) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd1.ErrNA } -func (x Provider) LookupByIndex(idx int64) (pd2.Node, error) { +func (x Provider) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Nodes.Node(), nil - case 1: + case 1: return x.Proto.Node(), nil } return nil, pd1.ErrNA } -func (x Provider) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x Provider) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Nodes": + case "0", "Nodes": return x.Nodes.Node(), nil - case "1", "Proto": + case "1", "Proto": return x.Proto.Node(), nil } return nil, pd1.ErrNA } -func (x Provider) MapIterator() pd2.MapIterator { +func (x Provider) MapIterator() pd3.MapIterator { return &Provider_MapIterator{-1, &x} } -func (x Provider) ListIterator() pd2.ListIterator { +func (x Provider) ListIterator() pd3.ListIterator { return nil } @@ -2731,23 +2764,25 @@ func (x Provider) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x Provider) AsLink() (pd2.Link, error) { +func (x Provider) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x Provider) Prototype() pd2.NodePrototype { +func (x Provider) Prototype() pd3.NodePrototype { return nil } // -- protocol type Node -- type Node struct { - Peer *Peer + Peer *Peer + + } -func (x *Node) Parse(n pd2.Node) error { +func (x *Node) Parse(n pd3.Node) error { *x = Node{} - if n.Kind() != pd2.Kind_Map { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() @@ -2757,7 +2792,7 @@ func (x *Node) Parse(n pd2.Node) error { } k, err := kn.AsString() if err != nil { - return pd3.Errorf("inductive map key is not a string") + return pd2.Errorf("inductive map key is not a string") } switch k { case "Peer": @@ -2768,9 +2803,10 @@ func (x *Node) Parse(n pd2.Node) error { x.Peer = &y return nil + } - return pd3.Errorf("inductive map has no applicable keys") + return pd2.Errorf("inductive map has no applicable keys") } @@ -2779,17 +2815,18 @@ type Node_MapIterator struct { s *Node } -func (x *Node_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *Node_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { if x.done { return nil, nil, pd1.ErrNA } else { x.done = true switch { - case x.s.Peer != nil: + case x.s.Peer != nil: return pd1.String("Peer"), x.s.Peer.Node(), nil + default: - return nil, nil, pd3.Errorf("no inductive cases are set") + return nil, nil, pd2.Errorf("no inductive cases are set") } } } @@ -2798,25 +2835,26 @@ func (x *Node_MapIterator) Done() bool { return x.done } -func (x Node) Node() pd2.Node { +func (x Node) Node() pd3.Node { return x } -func (x Node) Kind() pd2.Kind { - return pd2.Kind_Map +func (x Node) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x Node) LookupByString(key string) (pd2.Node, error) { +func (x Node) LookupByString(key string) (pd3.Node, error) { switch { - case x.Peer != nil && key == "Peer": + case x.Peer != nil && key == "Peer": return x.Peer.Node(), nil + } return nil, pd1.ErrNA } -func (x Node) LookupByNode(key pd2.Node) (pd2.Node, error) { - if key.Kind() != pd2.Kind_String { +func (x Node) LookupByNode(key pd3.Node) (pd3.Node, error) { + if key.Kind() != pd3.Kind_String { return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { @@ -2826,24 +2864,25 @@ func (x Node) LookupByNode(key pd2.Node) (pd2.Node, error) { } } -func (x Node) LookupByIndex(idx int64) (pd2.Node, error) { +func (x Node) LookupByIndex(idx int64) (pd3.Node, error) { return nil, pd1.ErrNA } -func (x Node) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x Node) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "Peer": + case "Peer": return x.Peer.Node(), nil + } return nil, pd1.ErrNA } -func (x Node) MapIterator() pd2.MapIterator { +func (x Node) MapIterator() pd3.MapIterator { return &Node_MapIterator{false, &x} } -func (x Node) ListIterator() pd2.ListIterator { +func (x Node) ListIterator() pd3.ListIterator { return nil } @@ -2879,28 +2918,27 @@ func (x Node) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x Node) AsLink() (pd2.Link, error) { +func (x Node) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x Node) Prototype() pd2.NodePrototype { +func (x Node) Prototype() pd3.NodePrototype { return nil } - // -- protocol type AnonList17 -- type AnonList17 []pd1.Bytes -func (v AnonList17) Node() pd2.Node { +func (v AnonList17) Node() pd3.Node { return v } -func (v *AnonList17) Parse(n pd2.Node) error { - if n.Kind() == pd2.Kind_Null { +func (v *AnonList17) Parse(n pd3.Node) error { + if n.Kind() == pd3.Kind_Null { *v = nil return nil } - if n.Kind() != pd2.Kind_List { + if n.Kind() != pd3.Kind_List { return pd1.ErrNA } else { *v = make(AnonList17, n.Length()) @@ -2916,19 +2954,19 @@ func (v *AnonList17) Parse(n pd2.Node) error { } } -func (AnonList17) Kind() pd2.Kind { - return pd2.Kind_List +func (AnonList17) Kind() pd3.Kind { + return pd3.Kind_List } -func (AnonList17) LookupByString(string) (pd2.Node, error) { +func (AnonList17) LookupByString(string) (pd3.Node, error) { return nil, pd1.ErrNA } -func (AnonList17) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (AnonList17) LookupByNode(key pd3.Node) (pd3.Node, error) { return nil, pd1.ErrNA } -func (v AnonList17) LookupByIndex(i int64) (pd2.Node, error) { +func (v AnonList17) LookupByIndex(i int64) (pd3.Node, error) { if i < 0 || i >= v.Length() { return nil, pd1.ErrBounds } else { @@ -2936,7 +2974,7 @@ func (v AnonList17) LookupByIndex(i int64) (pd2.Node, error) { } } -func (v AnonList17) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (v AnonList17) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { if i, err := seg.Index(); err != nil { return nil, pd1.ErrNA } else { @@ -2944,11 +2982,11 @@ func (v AnonList17) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { } } -func (AnonList17) MapIterator() pd2.MapIterator { +func (AnonList17) MapIterator() pd3.MapIterator { return nil } -func (v AnonList17) ListIterator() pd2.ListIterator { +func (v AnonList17) ListIterator() pd3.ListIterator { return &AnonList17_ListIterator{v, 0} } @@ -2984,11 +3022,11 @@ func (AnonList17) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (AnonList17) AsLink() (pd2.Link, error) { +func (AnonList17) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (AnonList17) Prototype() pd2.NodePrototype { +func (AnonList17) Prototype() pd3.NodePrototype { return nil // not needed } @@ -2997,7 +3035,7 @@ type AnonList17_ListIterator struct { at int64 } -func (iter *AnonList17_ListIterator) Next() (int64, pd2.Node, error) { +func (iter *AnonList17_ListIterator) Next() (int64, pd3.Node, error) { if iter.Done() { return -1, nil, pd1.ErrBounds } @@ -3010,59 +3048,60 @@ func (iter *AnonList17_ListIterator) Next() (int64, pd2.Node, error) { func (iter *AnonList17_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type Peer -- type Peer struct { - ID pd1.Bytes - Multiaddresses AnonList17 + ID pd1.Bytes + Multiaddresses AnonList17 + } -func (x Peer) Node() pd2.Node { +func (x Peer) Node() pd3.Node { return x } -func (x *Peer) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *Peer) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "ID": x.ID.Parse, + "ID": x.ID.Parse, "Multiaddresses": x.Multiaddresses.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "ID": - if _, notParsed := fieldMap["ID"]; !notParsed { - return pd3.Errorf("field %s already parsed", "ID") - } - if err := x.ID.Parse(vn); err != nil { - return err - } - delete(fieldMap, "ID") - case "Multiaddresses": - if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Multiaddresses") - } - if err := x.Multiaddresses.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Multiaddresses") + case "ID": + if _, notParsed := fieldMap["ID"]; !notParsed { + return pd2.Errorf("field %s already parsed", "ID") + } + if err := x.ID.Parse(vn); err != nil { + return err + } + delete(fieldMap, "ID") + case "Multiaddresses": + if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Multiaddresses") + } + if err := x.Multiaddresses.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Multiaddresses") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -3074,46 +3113,46 @@ type Peer_MapIterator struct { s *Peer } -func (x *Peer_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *Peer_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("ID"), x.s.ID.Node(), nil - case 1: - return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil + case 0: + return pd1.String("ID"), x.s.ID.Node(), nil + case 1: + return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Peer_MapIterator) Done() bool { - return x.i+1 >= 2 + return x.i + 1 >= 2 } -func (x Peer) Kind() pd2.Kind { - return pd2.Kind_Map +func (x Peer) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x Peer) LookupByString(key string) (pd2.Node, error) { +func (x Peer) LookupByString(key string) (pd3.Node, error) { switch key { - case "ID": + case "ID": return x.ID.Node(), nil - case "Multiaddresses": + case "Multiaddresses": return x.Multiaddresses.Node(), nil } return nil, pd1.ErrNA } -func (x Peer) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x Peer) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -3123,33 +3162,33 @@ func (x Peer) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd1.ErrNA } -func (x Peer) LookupByIndex(idx int64) (pd2.Node, error) { +func (x Peer) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.ID.Node(), nil - case 1: + case 1: return x.Multiaddresses.Node(), nil } return nil, pd1.ErrNA } -func (x Peer) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x Peer) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "ID": + case "0", "ID": return x.ID.Node(), nil - case "1", "Multiaddresses": + case "1", "Multiaddresses": return x.Multiaddresses.Node(), nil } return nil, pd1.ErrNA } -func (x Peer) MapIterator() pd2.MapIterator { +func (x Peer) MapIterator() pd3.MapIterator { return &Peer_MapIterator{-1, &x} } -func (x Peer) ListIterator() pd2.ListIterator { +func (x Peer) ListIterator() pd3.ListIterator { return nil } @@ -3185,23 +3224,25 @@ func (x Peer) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x Peer) AsLink() (pd2.Link, error) { +func (x Peer) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x Peer) Prototype() pd2.NodePrototype { +func (x Peer) Prototype() pd3.NodePrototype { return nil } // -- protocol type TransferProto -- type TransferProto struct { - Bitswap *BitswapTransfer + Bitswap *BitswapTransfer + + } -func (x *TransferProto) Parse(n pd2.Node) error { +func (x *TransferProto) Parse(n pd3.Node) error { *x = TransferProto{} - if n.Kind() != pd2.Kind_Map { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() @@ -3211,7 +3252,7 @@ func (x *TransferProto) Parse(n pd2.Node) error { } k, err := kn.AsString() if err != nil { - return pd3.Errorf("inductive map key is not a string") + return pd2.Errorf("inductive map key is not a string") } switch k { case "Bitswap": @@ -3222,9 +3263,10 @@ func (x *TransferProto) Parse(n pd2.Node) error { x.Bitswap = &y return nil + } - return pd3.Errorf("inductive map has no applicable keys") + return pd2.Errorf("inductive map has no applicable keys") } @@ -3233,17 +3275,18 @@ type TransferProto_MapIterator struct { s *TransferProto } -func (x *TransferProto_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *TransferProto_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { if x.done { return nil, nil, pd1.ErrNA } else { x.done = true switch { - case x.s.Bitswap != nil: + case x.s.Bitswap != nil: return pd1.String("Bitswap"), x.s.Bitswap.Node(), nil + default: - return nil, nil, pd3.Errorf("no inductive cases are set") + return nil, nil, pd2.Errorf("no inductive cases are set") } } } @@ -3252,25 +3295,26 @@ func (x *TransferProto_MapIterator) Done() bool { return x.done } -func (x TransferProto) Node() pd2.Node { +func (x TransferProto) Node() pd3.Node { return x } -func (x TransferProto) Kind() pd2.Kind { - return pd2.Kind_Map +func (x TransferProto) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x TransferProto) LookupByString(key string) (pd2.Node, error) { +func (x TransferProto) LookupByString(key string) (pd3.Node, error) { switch { - case x.Bitswap != nil && key == "Bitswap": + case x.Bitswap != nil && key == "Bitswap": return x.Bitswap.Node(), nil + } return nil, pd1.ErrNA } -func (x TransferProto) LookupByNode(key pd2.Node) (pd2.Node, error) { - if key.Kind() != pd2.Kind_String { +func (x TransferProto) LookupByNode(key pd3.Node) (pd3.Node, error) { + if key.Kind() != pd3.Kind_String { return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { @@ -3280,24 +3324,25 @@ func (x TransferProto) LookupByNode(key pd2.Node) (pd2.Node, error) { } } -func (x TransferProto) LookupByIndex(idx int64) (pd2.Node, error) { +func (x TransferProto) LookupByIndex(idx int64) (pd3.Node, error) { return nil, pd1.ErrNA } -func (x TransferProto) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x TransferProto) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "Bitswap": + case "Bitswap": return x.Bitswap.Node(), nil + } return nil, pd1.ErrNA } -func (x TransferProto) MapIterator() pd2.MapIterator { +func (x TransferProto) MapIterator() pd3.MapIterator { return &TransferProto_MapIterator{false, &x} } -func (x TransferProto) ListIterator() pd2.ListIterator { +func (x TransferProto) ListIterator() pd3.ListIterator { return nil } @@ -3333,35 +3378,37 @@ func (x TransferProto) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x TransferProto) AsLink() (pd2.Link, error) { +func (x TransferProto) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x TransferProto) Prototype() pd2.NodePrototype { +func (x TransferProto) Prototype() pd3.NodePrototype { return nil } - // -- protocol type BitswapTransfer -- type BitswapTransfer struct { + } -func (x BitswapTransfer) Node() pd2.Node { +func (x BitswapTransfer) Node() pd3.Node { return x } -func (x *BitswapTransfer) Parse(n pd2.Node) error { - if n.Kind() != pd2.Kind_Map { +func (x *BitswapTransfer) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{ + + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { @@ -3371,7 +3418,7 @@ func (x *BitswapTransfer) Parse(n pd2.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd2.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -3383,7 +3430,7 @@ type BitswapTransfer_MapIterator struct { s *BitswapTransfer } -func (x *BitswapTransfer_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { +func (x *BitswapTransfer_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { @@ -3392,29 +3439,29 @@ func (x *BitswapTransfer_MapIterator) Next() (key pd2.Node, value pd2.Node, err } func (x *BitswapTransfer_MapIterator) Done() bool { - return x.i+1 >= 0 + return x.i + 1 >= 0 } -func (x BitswapTransfer) Kind() pd2.Kind { - return pd2.Kind_Map +func (x BitswapTransfer) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x BitswapTransfer) LookupByString(key string) (pd2.Node, error) { +func (x BitswapTransfer) LookupByString(key string) (pd3.Node, error) { switch key { } return nil, pd1.ErrNA } -func (x BitswapTransfer) LookupByNode(key pd2.Node) (pd2.Node, error) { +func (x BitswapTransfer) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd2.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd2.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { @@ -3424,25 +3471,25 @@ func (x BitswapTransfer) LookupByNode(key pd2.Node) (pd2.Node, error) { return nil, pd1.ErrNA } -func (x BitswapTransfer) LookupByIndex(idx int64) (pd2.Node, error) { +func (x BitswapTransfer) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { } return nil, pd1.ErrNA } -func (x BitswapTransfer) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { +func (x BitswapTransfer) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { } return nil, pd1.ErrNA } -func (x BitswapTransfer) MapIterator() pd2.MapIterator { +func (x BitswapTransfer) MapIterator() pd3.MapIterator { return &BitswapTransfer_MapIterator{-1, &x} } -func (x BitswapTransfer) ListIterator() pd2.ListIterator { +func (x BitswapTransfer) ListIterator() pd3.ListIterator { return nil } @@ -3478,10 +3525,10 @@ func (x BitswapTransfer) AsBytes() ([]byte, error) { return nil, pd1.ErrNA } -func (x BitswapTransfer) AsLink() (pd2.Link, error) { +func (x BitswapTransfer) AsLink() (pd3.Link, error) { return nil, pd1.ErrNA } -func (x BitswapTransfer) Prototype() pd2.NodePrototype { +func (x BitswapTransfer) Prototype() pd3.NodePrototype { return nil } diff --git a/examples/greeting-service/api/proto/proto_edelweiss.go b/examples/greeting-service/api/proto/proto_edelweiss.go index 855c9be..4a064de 100644 --- a/examples/greeting-service/api/proto/proto_edelweiss.go +++ b/examples/greeting-service/api/proto/proto_edelweiss.go @@ -2,46 +2,48 @@ package proto -import ( - pd12 "bytes" +import( + pd1 "github.com/ipld/edelweiss/values" + pd2 "fmt" + pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd4 "net/http" + pd5 "github.com/ipfs/go-log/v2" + pd6 "bytes" pd7 "context" - pd8 "errors" - pd3 "fmt" - pd11 "io" - pd15 "io/ioutil" - pd5 "net/http" - pd4 "net/url" - pd13 "sync" - - pd14 "github.com/ipfs/go-log/v2" - pd10 "github.com/ipld/edelweiss/services" - pd2 "github.com/ipld/edelweiss/values" - pd9 "github.com/ipld/go-ipld-prime" - pd6 "github.com/ipld/go-ipld-prime/codec/dagjson" - pd1 "github.com/ipld/go-ipld-prime/datamodel" + pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd9 "errors" + pd10 "io" + pd11 "github.com/ipld/go-ipld-prime" + pd12 "net/url" + pd13 "github.com/ipld/edelweiss/services" + pd14 "sync" ) + // -- protocol type GreetingService_IdentifyArg -- type GreetingService_IdentifyArg struct { + } -func (x GreetingService_IdentifyArg) Node() pd1.Node { +func (x GreetingService_IdentifyArg) Node() pd3.Node { return x } -func (x *GreetingService_IdentifyArg) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *GreetingService_IdentifyArg) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{ + + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { @@ -51,7 +53,7 @@ func (x *GreetingService_IdentifyArg) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -63,66 +65,66 @@ type GreetingService_IdentifyArg_MapIterator struct { s *GreetingService_IdentifyArg } -func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *GreetingService_IdentifyArg_MapIterator) Done() bool { - return x.i+1 >= 0 + return x.i + 1 >= 0 } -func (x GreetingService_IdentifyArg) Kind() pd1.Kind { - return pd1.Kind_Map +func (x GreetingService_IdentifyArg) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x GreetingService_IdentifyArg) LookupByString(key string) (pd1.Node, error) { +func (x GreetingService_IdentifyArg) LookupByString(key string) (pd3.Node, error) { switch key { } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x GreetingService_IdentifyArg) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) LookupByIndex(idx int64) (pd1.Node, error) { +func (x GreetingService_IdentifyArg) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x GreetingService_IdentifyArg) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) MapIterator() pd1.MapIterator { +func (x GreetingService_IdentifyArg) MapIterator() pd3.MapIterator { return &GreetingService_IdentifyArg_MapIterator{-1, &x} } -func (x GreetingService_IdentifyArg) ListIterator() pd1.ListIterator { +func (x GreetingService_IdentifyArg) ListIterator() pd3.ListIterator { return nil } @@ -139,54 +141,54 @@ func (x GreetingService_IdentifyArg) IsNull() bool { } func (x GreetingService_IdentifyArg) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x GreetingService_IdentifyArg) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_IdentifyArg) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_IdentifyArg) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x GreetingService_IdentifyArg) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x GreetingService_IdentifyArg) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) Prototype() pd1.NodePrototype { +func (x GreetingService_IdentifyArg) Prototype() pd3.NodePrototype { return nil } // -- protocol type AnonList1 -- -type AnonList1 []pd2.String +type AnonList1 []pd1.String -func (v AnonList1) Node() pd1.Node { +func (v AnonList1) Node() pd3.Node { return v } -func (v *AnonList1) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AnonList1) Parse(n pd3.Node) error { + if n.Kind() == pd3.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd2.ErrNA + if n.Kind() != pd3.Kind_List { + return pd1.ErrNA } else { *v = make(AnonList1, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd2.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -195,39 +197,39 @@ func (v *AnonList1) Parse(n pd1.Node) error { } } -func (AnonList1) Kind() pd1.Kind { - return pd1.Kind_List +func (AnonList1) Kind() pd3.Kind { + return pd3.Kind_List } -func (AnonList1) LookupByString(string) (pd1.Node, error) { - return nil, pd2.ErrNA +func (AnonList1) LookupByString(string) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (AnonList1) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd2.ErrNA +func (AnonList1) LookupByNode(key pd3.Node) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (v AnonList1) LookupByIndex(i int64) (pd1.Node, error) { +func (v AnonList1) LookupByIndex(i int64) (pd3.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd2.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList1) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AnonList1) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList1) MapIterator() pd1.MapIterator { +func (AnonList1) MapIterator() pd3.MapIterator { return nil } -func (v AnonList1) ListIterator() pd1.ListIterator { +func (v AnonList1) ListIterator() pd3.ListIterator { return &AnonList1_ListIterator{v, 0} } @@ -244,30 +246,30 @@ func (AnonList1) IsNull() bool { } func (v AnonList1) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (AnonList1) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (AnonList1) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (AnonList1) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (AnonList1) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (AnonList1) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (AnonList1) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (AnonList1) Prototype() pd1.NodePrototype { +func (AnonList1) Prototype() pd3.NodePrototype { return nil // not needed } @@ -276,9 +278,9 @@ type AnonList1_ListIterator struct { at int64 } -func (iter *AnonList1_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AnonList1_ListIterator) Next() (int64, pd3.Node, error) { if iter.Done() { - return -1, nil, pd2.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -289,49 +291,50 @@ func (iter *AnonList1_ListIterator) Next() (int64, pd1.Node, error) { func (iter *AnonList1_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type GreetingService_IdentifyResult -- type GreetingService_IdentifyResult struct { - Methods AnonList1 + Methods AnonList1 + } -func (x GreetingService_IdentifyResult) Node() pd1.Node { +func (x GreetingService_IdentifyResult) Node() pd3.Node { return x } -func (x *GreetingService_IdentifyResult) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *GreetingService_IdentifyResult) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ - "Methods": x.Methods.Parse, + fieldMap := map[string]pd1.ParseFunc{ + "Methods": x.Methods.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Methods": - if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Methods") - } - if err := x.Methods.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Methods") + case "Methods": + if _, notParsed := fieldMap["Methods"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Methods") + } + if err := x.Methods.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Methods") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -343,74 +346,74 @@ type GreetingService_IdentifyResult_MapIterator struct { s *GreetingService_IdentifyResult } -func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd2.String("Methods"), x.s.Methods.Node(), nil + case 0: + return pd1.String("Methods"), x.s.Methods.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *GreetingService_IdentifyResult_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } -func (x GreetingService_IdentifyResult) Kind() pd1.Kind { - return pd1.Kind_Map +func (x GreetingService_IdentifyResult) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x GreetingService_IdentifyResult) LookupByString(key string) (pd1.Node, error) { +func (x GreetingService_IdentifyResult) LookupByString(key string) (pd3.Node, error) { switch key { - case "Methods": + case "Methods": return x.Methods.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x GreetingService_IdentifyResult) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd1.Node, error) { +func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Methods.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x GreetingService_IdentifyResult) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Methods": + case "0", "Methods": return x.Methods.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) MapIterator() pd1.MapIterator { +func (x GreetingService_IdentifyResult) MapIterator() pd3.MapIterator { return &GreetingService_IdentifyResult_MapIterator{-1, &x} } -func (x GreetingService_IdentifyResult) ListIterator() pd1.ListIterator { +func (x GreetingService_IdentifyResult) ListIterator() pd3.ListIterator { return nil } @@ -427,75 +430,77 @@ func (x GreetingService_IdentifyResult) IsNull() bool { } func (x GreetingService_IdentifyResult) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x GreetingService_IdentifyResult) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_IdentifyResult) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_IdentifyResult) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x GreetingService_IdentifyResult) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x GreetingService_IdentifyResult) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) Prototype() pd1.NodePrototype { +func (x GreetingService_IdentifyResult) Prototype() pd3.NodePrototype { return nil } // -- protocol type GreetingService_Error -- type GreetingService_Error struct { - Code pd2.String + Code pd1.String + } -func (x GreetingService_Error) Node() pd1.Node { +func (x GreetingService_Error) Node() pd3.Node { return x } -func (x *GreetingService_Error) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *GreetingService_Error) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ - "Code": x.Code.Parse, + fieldMap := map[string]pd1.ParseFunc{ + "Code": x.Code.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Code": - if _, notParsed := fieldMap["Code"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Code") - } - if err := x.Code.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Code") + case "Code": + if _, notParsed := fieldMap["Code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Code") + } + if err := x.Code.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Code") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -507,74 +512,74 @@ type GreetingService_Error_MapIterator struct { s *GreetingService_Error } -func (x *GreetingService_Error_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *GreetingService_Error_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd2.String("Code"), x.s.Code.Node(), nil + case 0: + return pd1.String("Code"), x.s.Code.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *GreetingService_Error_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } -func (x GreetingService_Error) Kind() pd1.Kind { - return pd1.Kind_Map +func (x GreetingService_Error) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x GreetingService_Error) LookupByString(key string) (pd1.Node, error) { +func (x GreetingService_Error) LookupByString(key string) (pd3.Node, error) { switch key { - case "Code": + case "Code": return x.Code.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x GreetingService_Error) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) LookupByIndex(idx int64) (pd1.Node, error) { +func (x GreetingService_Error) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Code.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x GreetingService_Error) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Code": + case "0", "Code": return x.Code.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) MapIterator() pd1.MapIterator { +func (x GreetingService_Error) MapIterator() pd3.MapIterator { return &GreetingService_Error_MapIterator{-1, &x} } -func (x GreetingService_Error) ListIterator() pd1.ListIterator { +func (x GreetingService_Error) ListIterator() pd3.ListIterator { return nil } @@ -591,44 +596,46 @@ func (x GreetingService_Error) IsNull() bool { } func (x GreetingService_Error) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x GreetingService_Error) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_Error) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_Error) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x GreetingService_Error) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x GreetingService_Error) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x GreetingService_Error) Prototype() pd1.NodePrototype { +func (x GreetingService_Error) Prototype() pd3.NodePrototype { return nil } // -- protocol type AnonInductive4 -- type AnonInductive4 struct { - Identify *GreetingService_IdentifyArg - Hello *HelloRequest + Identify *GreetingService_IdentifyArg + Hello *HelloRequest + + } -func (x *AnonInductive4) Parse(n pd1.Node) error { +func (x *AnonInductive4) Parse(n pd3.Node) error { *x = AnonInductive4{} - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -637,7 +644,7 @@ func (x *AnonInductive4) Parse(n pd1.Node) error { } k, err := kn.AsString() if err != nil { - return pd3.Errorf("inductive map key is not a string") + return pd2.Errorf("inductive map key is not a string") } switch k { case "IdentifyRequest": @@ -655,9 +662,10 @@ func (x *AnonInductive4) Parse(n pd1.Node) error { x.Hello = &y return nil + } - return pd3.Errorf("inductive map has no applicable keys") + return pd2.Errorf("inductive map has no applicable keys") } @@ -666,19 +674,20 @@ type AnonInductive4_MapIterator struct { s *AnonInductive4 } -func (x *AnonInductive4_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *AnonInductive4_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { if x.done { - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { - case x.s.Identify != nil: - return pd2.String("IdentifyRequest"), x.s.Identify.Node(), nil - case x.s.Hello != nil: - return pd2.String("HelloRequest"), x.s.Hello.Node(), nil + case x.s.Identify != nil: + return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil + case x.s.Hello != nil: + return pd1.String("HelloRequest"), x.s.Hello.Node(), nil + default: - return nil, nil, pd3.Errorf("no inductive cases are set") + return nil, nil, pd2.Errorf("no inductive cases are set") } } } @@ -687,28 +696,29 @@ func (x *AnonInductive4_MapIterator) Done() bool { return x.done } -func (x AnonInductive4) Node() pd1.Node { +func (x AnonInductive4) Node() pd3.Node { return x } -func (x AnonInductive4) Kind() pd1.Kind { - return pd1.Kind_Map +func (x AnonInductive4) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x AnonInductive4) LookupByString(key string) (pd1.Node, error) { +func (x AnonInductive4) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyRequest": + case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil - case x.Hello != nil && key == "HelloRequest": + case x.Hello != nil && key == "HelloRequest": return x.Hello.Node(), nil + } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd2.ErrNA +func (x AnonInductive4) LookupByNode(key pd3.Node) (pd3.Node, error) { + if key.Kind() != pd3.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -717,26 +727,27 @@ func (x AnonInductive4) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x AnonInductive4) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (x AnonInductive4) LookupByIndex(idx int64) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (x AnonInductive4) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x AnonInductive4) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyRequest": + case "IdentifyRequest": return x.Identify.Node(), nil - case "HelloRequest": + case "HelloRequest": return x.Hello.Node(), nil + } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) MapIterator() pd1.MapIterator { +func (x AnonInductive4) MapIterator() pd3.MapIterator { return &AnonInductive4_MapIterator{false, &x} } -func (x AnonInductive4) ListIterator() pd1.ListIterator { +func (x AnonInductive4) ListIterator() pd3.ListIterator { return nil } @@ -753,45 +764,46 @@ func (x AnonInductive4) IsNull() bool { } func (x AnonInductive4) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x AnonInductive4) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive4) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive4) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x AnonInductive4) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x AnonInductive4) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x AnonInductive4) Prototype() pd1.NodePrototype { +func (x AnonInductive4) Prototype() pd3.NodePrototype { return nil } - // -- protocol type AnonInductive5 -- type AnonInductive5 struct { - Identify *GreetingService_IdentifyResult - Hello *HelloResponse - Error *GreetingService_Error + Identify *GreetingService_IdentifyResult + Hello *HelloResponse + Error *GreetingService_Error + + } -func (x *AnonInductive5) Parse(n pd1.Node) error { +func (x *AnonInductive5) Parse(n pd3.Node) error { *x = AnonInductive5{} - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -800,7 +812,7 @@ func (x *AnonInductive5) Parse(n pd1.Node) error { } k, err := kn.AsString() if err != nil { - return pd3.Errorf("inductive map key is not a string") + return pd2.Errorf("inductive map key is not a string") } switch k { case "IdentifyResponse": @@ -825,9 +837,10 @@ func (x *AnonInductive5) Parse(n pd1.Node) error { x.Error = &y return nil + } - return pd3.Errorf("inductive map has no applicable keys") + return pd2.Errorf("inductive map has no applicable keys") } @@ -836,21 +849,22 @@ type AnonInductive5_MapIterator struct { s *AnonInductive5 } -func (x *AnonInductive5_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *AnonInductive5_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { if x.done { - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { - case x.s.Identify != nil: - return pd2.String("IdentifyResponse"), x.s.Identify.Node(), nil - case x.s.Hello != nil: - return pd2.String("HelloResponse"), x.s.Hello.Node(), nil - case x.s.Error != nil: - return pd2.String("Error"), x.s.Error.Node(), nil + case x.s.Identify != nil: + return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil + case x.s.Hello != nil: + return pd1.String("HelloResponse"), x.s.Hello.Node(), nil + case x.s.Error != nil: + return pd1.String("Error"), x.s.Error.Node(), nil + default: - return nil, nil, pd3.Errorf("no inductive cases are set") + return nil, nil, pd2.Errorf("no inductive cases are set") } } } @@ -859,30 +873,31 @@ func (x *AnonInductive5_MapIterator) Done() bool { return x.done } -func (x AnonInductive5) Node() pd1.Node { +func (x AnonInductive5) Node() pd3.Node { return x } -func (x AnonInductive5) Kind() pd1.Kind { - return pd1.Kind_Map +func (x AnonInductive5) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x AnonInductive5) LookupByString(key string) (pd1.Node, error) { +func (x AnonInductive5) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyResponse": + case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil - case x.Hello != nil && key == "HelloResponse": + case x.Hello != nil && key == "HelloResponse": return x.Hello.Node(), nil - case x.Error != nil && key == "Error": + case x.Error != nil && key == "Error": return x.Error.Node(), nil + } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd2.ErrNA +func (x AnonInductive5) LookupByNode(key pd3.Node) (pd3.Node, error) { + if key.Kind() != pd3.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -891,28 +906,29 @@ func (x AnonInductive5) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x AnonInductive5) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (x AnonInductive5) LookupByIndex(idx int64) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (x AnonInductive5) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x AnonInductive5) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyResponse": + case "IdentifyResponse": return x.Identify.Node(), nil - case "HelloResponse": + case "HelloResponse": return x.Hello.Node(), nil - case "Error": + case "Error": return x.Error.Node(), nil + } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) MapIterator() pd1.MapIterator { +func (x AnonInductive5) MapIterator() pd3.MapIterator { return &AnonInductive5_MapIterator{false, &x} } -func (x AnonInductive5) ListIterator() pd1.ListIterator { +func (x AnonInductive5) ListIterator() pd3.ListIterator { return nil } @@ -929,45 +945,48 @@ func (x AnonInductive5) IsNull() bool { } func (x AnonInductive5) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x AnonInductive5) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive5) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive5) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x AnonInductive5) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x AnonInductive5) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x AnonInductive5) Prototype() pd1.NodePrototype { +func (x AnonInductive5) Prototype() pd3.NodePrototype { return nil } - -var logger_client_GreetingService = pd14.Logger("service/client/greetingservice") +var logger_client_GreetingService = pd5.Logger("service/client/greetingservice") type GreetingService_Client interface { - Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) - Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) +Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) + +Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) + - Identify_Async(ctx pd7.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) +Identify_Async(ctx pd7.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) + +Hello_Async(ctx pd7.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) - Hello_Async(ctx pd7.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) } + type GreetingService_Identify_AsyncResult struct { Resp *GreetingService_IdentifyResult Err error @@ -978,16 +997,17 @@ type GreetingService_Hello_AsyncResult struct { Err error } + type GreetingService_ClientOption func(*client_GreetingService) error type client_GreetingService struct { - httpClient *pd5.Client - endpoint *pd4.URL - ulk pd13.Mutex + httpClient *pd4.Client + endpoint *pd12.URL + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } -func GreetingService_Client_WithHTTPClient(hc *pd5.Client) GreetingService_ClientOption { +func GreetingService_Client_WithHTTPClient(hc *pd4.Client) GreetingService_ClientOption { return func(c *client_GreetingService) error { c.httpClient = hc return nil @@ -995,11 +1015,11 @@ func GreetingService_Client_WithHTTPClient(hc *pd5.Client) GreetingService_Clien } func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientOption) (*client_GreetingService, error) { - u, err := pd4.Parse(endpoint) + u, err := pd12.Parse(endpoint) if err != nil { return nil, err } - c := &client_GreetingService{endpoint: u, httpClient: pd5.DefaultClient, unsupported: make(map[string]bool)} + c := &client_GreetingService{endpoint: u, httpClient: pd4.DefaultClient, unsupported: make(map[string]bool)} for _, o := range opts { if err := o(c); err != nil { return nil, err @@ -1008,6 +1028,8 @@ func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientO return c, nil } + + func (c *client_GreetingService) Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1043,21 +1065,21 @@ func (c *client_GreetingService) Identify_Async(ctx pd7.Context, req *GreetingSe notSupported := c.unsupported["Identify"] c.ulk.Unlock() if notSupported { - return nil, pd10.ErrSchema + return nil, pd13.ErrSchema } envelope := &AnonInductive4{ Identify: req, } - buf, err := pd9.Encode(envelope, pd6.Encode) + buf, err := pd11.Encode(envelope, pd8.Encode) if err != nil { - return nil, pd3.Errorf("unexpected serialization error (%v)", err) + return nil, pd2.Errorf("serializing DAG-JSON request: %w", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd5.NewRequestWithContext(ctx, "POST", u.String(), pd12.NewReader(buf)) + httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd6.NewReader(buf)) if err != nil { return nil, err } @@ -1069,7 +1091,7 @@ func (c *client_GreetingService) Identify_Async(ctx pd7.Context, req *GreetingSe resp, err := c.httpClient.Do(httpReq) if err != nil { - return nil, pd3.Errorf("sending HTTP request: %w", err) + return nil, pd2.Errorf("sending HTTP request: %w", err) } // HTTP codes 400 and 404 correspond to unrecognized method or request schema @@ -1079,7 +1101,7 @@ func (c *client_GreetingService) Identify_Async(ctx pd7.Context, req *GreetingSe c.ulk.Lock() c.unsupported["Identify"] = true c.ulk.Unlock() - return nil, pd10.ErrSchema + return nil, pd13.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1087,12 +1109,12 @@ func (c *client_GreetingService) Identify_Async(ctx pd7.Context, req *GreetingSe resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd10.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd13.ErrService{Cause: pd2.Errorf("%s", errValues[0])} } else { - err = pd3.Errorf("service rejected the call, no cause provided") + err = pd2.Errorf("service rejected the call, no cause provided") } } else { - err = pd3.Errorf("service rejected the call") + err = pd2.Errorf("service rejected the call") } return nil, err } @@ -1102,35 +1124,35 @@ func (c *client_GreetingService) Identify_Async(ctx pd7.Context, req *GreetingSe return ch, nil } -func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- GreetingService_Identify_AsyncResult, r pd11.ReadCloser) { +func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- GreetingService_Identify_AsyncResult, r pd10.ReadCloser) { defer close(ch) defer r.Close() - opt := pd6.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + opt := pd8.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { var out GreetingService_Identify_AsyncResult - n, err := pd9.DecodeStreaming(r, opt.Decode) + n, err := pd11.DecodeStreaming(r, opt.Decode) - if pd8.Is(err, pd11.EOF) || pd8.Is(err, pd11.ErrUnexpectedEOF) || pd8.Is(err, pd7.DeadlineExceeded) || pd8.Is(err, pd7.Canceled) { + if pd9.Is(err, pd10.EOF) || pd9.Is(err, pd10.ErrUnexpectedEOF) || pd9.Is(err, pd7.DeadlineExceeded) || pd9.Is(err, pd7.Canceled) { return } if err != nil { - out = GreetingService_Identify_AsyncResult{Err: pd10.ErrProto{Cause: err}} // IPLD decode error + out = GreetingService_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error } else { var x [1]byte if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { - out = GreetingService_Identify_AsyncResult{Err: pd10.ErrProto{Cause: pd3.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error + out = GreetingService_Identify_AsyncResult{Err: pd13.ErrProto{Cause: pd2.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { env := &AnonInductive5{} if err = env.Parse(n); err != nil { - out = GreetingService_Identify_AsyncResult{Err: pd10.ErrProto{Cause: err}} // schema decode error + out = GreetingService_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error } else if env.Error != nil { - out = GreetingService_Identify_AsyncResult{Err: pd10.ErrService{Cause: pd8.New(string(env.Error.Code))}} // service-level error + out = GreetingService_Identify_AsyncResult{Err: pd13.ErrService{Cause: pd9.New(string(env.Error.Code))}} // service-level error } else if env.Identify != nil { out = GreetingService_Identify_AsyncResult{Resp: env.Identify} } else { @@ -1140,13 +1162,14 @@ func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- Gre } select { - case <-ctx.Done(): - return - case ch <- out: + case <- ctx.Done(): + return + case ch <- out: } } } + func (c *client_GreetingService) Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1182,21 +1205,21 @@ func (c *client_GreetingService) Hello_Async(ctx pd7.Context, req *HelloRequest) notSupported := c.unsupported["Hello"] c.ulk.Unlock() if notSupported { - return nil, pd10.ErrSchema + return nil, pd13.ErrSchema } envelope := &AnonInductive4{ Hello: req, } - buf, err := pd9.Encode(envelope, pd6.Encode) + buf, err := pd11.Encode(envelope, pd8.Encode) if err != nil { - return nil, pd3.Errorf("unexpected serialization error (%v)", err) + return nil, pd2.Errorf("serializing DAG-JSON request: %w", err) } // encode request in URL u := *c.endpoint - httpReq, err := pd5.NewRequestWithContext(ctx, "POST", u.String(), pd12.NewReader(buf)) + httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd6.NewReader(buf)) if err != nil { return nil, err } @@ -1208,7 +1231,7 @@ func (c *client_GreetingService) Hello_Async(ctx pd7.Context, req *HelloRequest) resp, err := c.httpClient.Do(httpReq) if err != nil { - return nil, pd3.Errorf("sending HTTP request: %w", err) + return nil, pd2.Errorf("sending HTTP request: %w", err) } // HTTP codes 400 and 404 correspond to unrecognized method or request schema @@ -1218,7 +1241,7 @@ func (c *client_GreetingService) Hello_Async(ctx pd7.Context, req *HelloRequest) c.ulk.Lock() c.unsupported["Hello"] = true c.ulk.Unlock() - return nil, pd10.ErrSchema + return nil, pd13.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1226,12 +1249,12 @@ func (c *client_GreetingService) Hello_Async(ctx pd7.Context, req *HelloRequest) resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd10.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd13.ErrService{Cause: pd2.Errorf("%s", errValues[0])} } else { - err = pd3.Errorf("service rejected the call, no cause provided") + err = pd2.Errorf("service rejected the call, no cause provided") } } else { - err = pd3.Errorf("service rejected the call") + err = pd2.Errorf("service rejected the call") } return nil, err } @@ -1241,35 +1264,35 @@ func (c *client_GreetingService) Hello_Async(ctx pd7.Context, req *HelloRequest) return ch, nil } -func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- GreetingService_Hello_AsyncResult, r pd11.ReadCloser) { +func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- GreetingService_Hello_AsyncResult, r pd10.ReadCloser) { defer close(ch) defer r.Close() - opt := pd6.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + opt := pd8.DecodeOptions{ + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { var out GreetingService_Hello_AsyncResult - n, err := pd9.DecodeStreaming(r, opt.Decode) + n, err := pd11.DecodeStreaming(r, opt.Decode) - if pd8.Is(err, pd11.EOF) || pd8.Is(err, pd11.ErrUnexpectedEOF) || pd8.Is(err, pd7.DeadlineExceeded) || pd8.Is(err, pd7.Canceled) { + if pd9.Is(err, pd10.EOF) || pd9.Is(err, pd10.ErrUnexpectedEOF) || pd9.Is(err, pd7.DeadlineExceeded) || pd9.Is(err, pd7.Canceled) { return } if err != nil { - out = GreetingService_Hello_AsyncResult{Err: pd10.ErrProto{Cause: err}} // IPLD decode error + out = GreetingService_Hello_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error } else { var x [1]byte if k, err := r.Read(x[:]); k != 1 || x[0] != '\n' { - out = GreetingService_Hello_AsyncResult{Err: pd10.ErrProto{Cause: pd3.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error + out = GreetingService_Hello_AsyncResult{Err: pd13.ErrProto{Cause: pd2.Errorf("missing new line after result: err (%v), read (%d), char (%q)", err, k, string(x[:]))}} // Edelweiss decode error } else { env := &AnonInductive5{} if err = env.Parse(n); err != nil { - out = GreetingService_Hello_AsyncResult{Err: pd10.ErrProto{Cause: err}} // schema decode error + out = GreetingService_Hello_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error } else if env.Error != nil { - out = GreetingService_Hello_AsyncResult{Err: pd10.ErrService{Cause: pd8.New(string(env.Error.Code))}} // service-level error + out = GreetingService_Hello_AsyncResult{Err: pd13.ErrService{Cause: pd9.New(string(env.Error.Code))}} // service-level error } else if env.Hello != nil { out = GreetingService_Hello_AsyncResult{Resp: env.Hello} } else { @@ -1279,29 +1302,31 @@ func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- Greeti } select { - case <-ctx.Done(): - return - case ch <- out: + case <- ctx.Done(): + return + case ch <- out: } } } -var logger_server_GreetingService = pd14.Logger("service/server/greetingservice") + +var logger_server_GreetingService = pd5.Logger("service/server/greetingservice") type GreetingService_Server interface { + Hello(ctx pd7.Context, req *HelloRequest) (<-chan *GreetingService_Hello_AsyncResult, error) } -func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { - return func(writer pd5.ResponseWriter, request *pd5.Request) { +func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { + return func(writer pd4.ResponseWriter, request *pd4.Request) { // parse request - msg, err := pd15.ReadAll(request.Body) + msg, err := pd10.ReadAll(request.Body) if err != nil { logger_server_GreetingService.Errorf("reading request body (%v)", err) writer.WriteHeader(400) return } - n, err := pd9.Decode(msg, pd6.Decode) + n, err := pd11.Decode(msg, pd8.Decode) if err != nil { logger_server_GreetingService.Errorf("received request not decodeable (%v)", err) writer.WriteHeader(400) @@ -1331,7 +1356,7 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { } writer.WriteHeader(200) - if f, ok := writer.(pd5.Flusher); ok { + if f, ok := writer.(pd4.Flusher); ok { f.Flush() } @@ -1345,34 +1370,36 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { } var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{Error: &GreetingService_Error{Code: pd2.String(resp.Err.Error())}} + env = &AnonInductive5{ Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())} } } else { - env = &AnonInductive5{Hello: resp.Resp} + env = &AnonInductive5{ Hello: resp.Resp } } - var buf pd12.Buffer - if err = pd9.EncodeStreaming(&buf, env, pd6.Encode); err != nil { + var buf pd6.Buffer + if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { logger_server_GreetingService.Errorf("cannot encode response (%v)", err) continue } buf.WriteByte("\n"[0]) writer.Write(buf.Bytes()) - if f, ok := writer.(pd5.Flusher); ok { + if f, ok := writer.(pd4.Flusher); ok { f.Flush() } } } + case env.Identify != nil: var env *AnonInductive5 env = &AnonInductive5{ Identify: &GreetingService_IdentifyResult{ - Methods: []pd2.String{ + Methods: []pd1.String{ "Hello", + }, }, } - var buf pd12.Buffer - if err = pd9.EncodeStreaming(&buf, env, pd6.Encode); err != nil { + var buf pd6.Buffer + if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { logger_server_GreetingService.Errorf("cannot encode identify response (%v)", err) writer.WriteHeader(500) return @@ -1390,55 +1417,57 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { // -- protocol type HelloRequest -- type HelloRequest struct { - Name pd2.String - Address Address + Name pd1.String + Address Address + } -func (x HelloRequest) Node() pd1.Node { +func (x HelloRequest) Node() pd3.Node { return x } -func (x *HelloRequest) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *HelloRequest) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ - "Name": x.Name.Parse, + fieldMap := map[string]pd1.ParseFunc{ + "Name": x.Name.Parse, "Address": x.Address.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "Name": - if _, notParsed := fieldMap["Name"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Name") - } - if err := x.Name.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Name") - case "Address": - if _, notParsed := fieldMap["Address"]; !notParsed { - return pd3.Errorf("field %s already parsed", "Address") - } - if err := x.Address.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Address") + case "Name": + if _, notParsed := fieldMap["Name"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Name") + } + if err := x.Name.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Name") + case "Address": + if _, notParsed := fieldMap["Address"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Address") + } + if err := x.Address.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Address") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -1450,82 +1479,82 @@ type HelloRequest_MapIterator struct { s *HelloRequest } -func (x *HelloRequest_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *HelloRequest_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd2.String("Name"), x.s.Name.Node(), nil - case 1: - return pd2.String("Address"), x.s.Address.Node(), nil + case 0: + return pd1.String("Name"), x.s.Name.Node(), nil + case 1: + return pd1.String("Address"), x.s.Address.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *HelloRequest_MapIterator) Done() bool { - return x.i+1 >= 2 + return x.i + 1 >= 2 } -func (x HelloRequest) Kind() pd1.Kind { - return pd1.Kind_Map +func (x HelloRequest) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x HelloRequest) LookupByString(key string) (pd1.Node, error) { +func (x HelloRequest) LookupByString(key string) (pd3.Node, error) { switch key { - case "Name": + case "Name": return x.Name.Node(), nil - case "Address": + case "Address": return x.Address.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x HelloRequest) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) LookupByIndex(idx int64) (pd1.Node, error) { +func (x HelloRequest) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Name.Node(), nil - case 1: + case 1: return x.Address.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x HelloRequest) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Name": + case "0", "Name": return x.Name.Node(), nil - case "1", "Address": + case "1", "Address": return x.Address.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) MapIterator() pd1.MapIterator { +func (x HelloRequest) MapIterator() pd3.MapIterator { return &HelloRequest_MapIterator{-1, &x} } -func (x HelloRequest) ListIterator() pd1.ListIterator { +func (x HelloRequest) ListIterator() pd3.ListIterator { return nil } @@ -1542,54 +1571,54 @@ func (x HelloRequest) IsNull() bool { } func (x HelloRequest) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x HelloRequest) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x HelloRequest) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x HelloRequest) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x HelloRequest) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x HelloRequest) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x HelloRequest) Prototype() pd1.NodePrototype { +func (x HelloRequest) Prototype() pd3.NodePrototype { return nil } // -- protocol type AddressLines -- -type AddressLines []pd2.String +type AddressLines []pd1.String -func (v AddressLines) Node() pd1.Node { +func (v AddressLines) Node() pd3.Node { return v } -func (v *AddressLines) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AddressLines) Parse(n pd3.Node) error { + if n.Kind() == pd3.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd2.ErrNA + if n.Kind() != pd3.Kind_List { + return pd1.ErrNA } else { *v = make(AddressLines, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd2.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -1598,39 +1627,39 @@ func (v *AddressLines) Parse(n pd1.Node) error { } } -func (AddressLines) Kind() pd1.Kind { - return pd1.Kind_List +func (AddressLines) Kind() pd3.Kind { + return pd3.Kind_List } -func (AddressLines) LookupByString(string) (pd1.Node, error) { - return nil, pd2.ErrNA +func (AddressLines) LookupByString(string) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (AddressLines) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd2.ErrNA +func (AddressLines) LookupByNode(key pd3.Node) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (v AddressLines) LookupByIndex(i int64) (pd1.Node, error) { +func (v AddressLines) LookupByIndex(i int64) (pd3.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd2.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AddressLines) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AddressLines) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AddressLines) MapIterator() pd1.MapIterator { +func (AddressLines) MapIterator() pd3.MapIterator { return nil } -func (v AddressLines) ListIterator() pd1.ListIterator { +func (v AddressLines) ListIterator() pd3.ListIterator { return &AddressLines_ListIterator{v, 0} } @@ -1647,30 +1676,30 @@ func (AddressLines) IsNull() bool { } func (v AddressLines) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (AddressLines) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (AddressLines) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (AddressLines) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (AddressLines) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (AddressLines) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (AddressLines) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (AddressLines) Prototype() pd1.NodePrototype { +func (AddressLines) Prototype() pd3.NodePrototype { return nil // not needed } @@ -1679,9 +1708,9 @@ type AddressLines_ListIterator struct { at int64 } -func (iter *AddressLines_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AddressLines_ListIterator) Next() (int64, pd3.Node, error) { if iter.Done() { - return -1, nil, pd2.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -1692,21 +1721,22 @@ func (iter *AddressLines_ListIterator) Next() (int64, pd1.Node, error) { func (iter *AddressLines_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type Address -- type Address struct { - US *USAddress - SK *SKAddress + US *USAddress + SK *SKAddress + + + OtherCountry string + OtherAddress *AddressLines - OtherCountry string - OtherAddress *AddressLines } -func (x *Address) Parse(n pd1.Node) error { +func (x *Address) Parse(n pd3.Node) error { *x = Address{} - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -1715,7 +1745,7 @@ func (x *Address) Parse(n pd1.Node) error { } k, err := kn.AsString() if err != nil { - return pd3.Errorf("inductive map key is not a string") + return pd2.Errorf("inductive map key is not a string") } switch k { case "US": @@ -1733,6 +1763,7 @@ func (x *Address) Parse(n pd1.Node) error { x.SK = &y return nil + default: var y AddressLines if err := y.Parse(vn); err != nil { @@ -1751,22 +1782,23 @@ type Address_MapIterator struct { s *Address } -func (x *Address_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *Address_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { if x.done { - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { - case x.s.US != nil: - return pd2.String("US"), x.s.US.Node(), nil - case x.s.SK != nil: - return pd2.String("SouthKorea"), x.s.SK.Node(), nil + case x.s.US != nil: + return pd1.String("US"), x.s.US.Node(), nil + case x.s.SK != nil: + return pd1.String("SouthKorea"), x.s.SK.Node(), nil - case x.s.OtherAddress != nil: - return pd2.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil + + case x.s.OtherAddress != nil: + return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil default: - return nil, nil, pd3.Errorf("no inductive cases are set") + return nil, nil, pd2.Errorf("no inductive cases are set") } } } @@ -1775,31 +1807,32 @@ func (x *Address_MapIterator) Done() bool { return x.done } -func (x Address) Node() pd1.Node { +func (x Address) Node() pd3.Node { return x } -func (x Address) Kind() pd1.Kind { - return pd1.Kind_Map +func (x Address) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x Address) LookupByString(key string) (pd1.Node, error) { +func (x Address) LookupByString(key string) (pd3.Node, error) { switch { - case x.US != nil && key == "US": + case x.US != nil && key == "US": return x.US.Node(), nil - case x.SK != nil && key == "SouthKorea": + case x.SK != nil && key == "SouthKorea": return x.SK.Node(), nil + case x.OtherAddress != nil && key == x.OtherCountry: return x.OtherAddress.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x Address) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd2.ErrNA +func (x Address) LookupByNode(key pd3.Node) (pd3.Node, error) { + if key.Kind() != pd3.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -1808,29 +1841,30 @@ func (x Address) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x Address) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (x Address) LookupByIndex(idx int64) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (x Address) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x Address) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "US": + case "US": return x.US.Node(), nil - case "SouthKorea": + case "SouthKorea": return x.SK.Node(), nil + case x.OtherCountry: return x.OtherAddress.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x Address) MapIterator() pd1.MapIterator { +func (x Address) MapIterator() pd3.MapIterator { return &Address_MapIterator{false, &x} } -func (x Address) ListIterator() pd1.ListIterator { +func (x Address) ListIterator() pd3.ListIterator { return nil } @@ -1847,105 +1881,106 @@ func (x Address) IsNull() bool { } func (x Address) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x Address) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x Address) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x Address) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x Address) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x Address) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x Address) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x Address) Prototype() pd1.NodePrototype { +func (x Address) Prototype() pd3.NodePrototype { return nil } - // -- protocol type USAddress -- type USAddress struct { - Street pd2.String - City pd2.String - State State - ZIP pd2.Int + Street pd1.String + City pd1.String + State State + ZIP pd1.Int + } -func (x USAddress) Node() pd1.Node { +func (x USAddress) Node() pd3.Node { return x } -func (x *USAddress) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *USAddress) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ - "street": x.Street.Parse, - "city": x.City.Parse, - "state": x.State.Parse, - "zip": x.ZIP.Parse, + fieldMap := map[string]pd1.ParseFunc{ + "street": x.Street.Parse, + "city": x.City.Parse, + "state": x.State.Parse, + "zip": x.ZIP.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "street": - if _, notParsed := fieldMap["street"]; !notParsed { - return pd3.Errorf("field %s already parsed", "street") - } - if err := x.Street.Parse(vn); err != nil { - return err - } - delete(fieldMap, "street") - case "city": - if _, notParsed := fieldMap["city"]; !notParsed { - return pd3.Errorf("field %s already parsed", "city") - } - if err := x.City.Parse(vn); err != nil { - return err - } - delete(fieldMap, "city") - case "state": - if _, notParsed := fieldMap["state"]; !notParsed { - return pd3.Errorf("field %s already parsed", "state") - } - if err := x.State.Parse(vn); err != nil { - return err - } - delete(fieldMap, "state") - case "zip": - if _, notParsed := fieldMap["zip"]; !notParsed { - return pd3.Errorf("field %s already parsed", "zip") - } - if err := x.ZIP.Parse(vn); err != nil { - return err - } - delete(fieldMap, "zip") + case "street": + if _, notParsed := fieldMap["street"]; !notParsed { + return pd2.Errorf("field %s already parsed", "street") + } + if err := x.Street.Parse(vn); err != nil { + return err + } + delete(fieldMap, "street") + case "city": + if _, notParsed := fieldMap["city"]; !notParsed { + return pd2.Errorf("field %s already parsed", "city") + } + if err := x.City.Parse(vn); err != nil { + return err + } + delete(fieldMap, "city") + case "state": + if _, notParsed := fieldMap["state"]; !notParsed { + return pd2.Errorf("field %s already parsed", "state") + } + if err := x.State.Parse(vn); err != nil { + return err + } + delete(fieldMap, "state") + case "zip": + if _, notParsed := fieldMap["zip"]; !notParsed { + return pd2.Errorf("field %s already parsed", "zip") + } + if err := x.ZIP.Parse(vn); err != nil { + return err + } + delete(fieldMap, "zip") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -1957,98 +1992,98 @@ type USAddress_MapIterator struct { s *USAddress } -func (x *USAddress_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *USAddress_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd2.String("street"), x.s.Street.Node(), nil - case 1: - return pd2.String("city"), x.s.City.Node(), nil - case 2: - return pd2.String("state"), x.s.State.Node(), nil - case 3: - return pd2.String("zip"), x.s.ZIP.Node(), nil + case 0: + return pd1.String("street"), x.s.Street.Node(), nil + case 1: + return pd1.String("city"), x.s.City.Node(), nil + case 2: + return pd1.String("state"), x.s.State.Node(), nil + case 3: + return pd1.String("zip"), x.s.ZIP.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *USAddress_MapIterator) Done() bool { - return x.i+1 >= 4 + return x.i + 1 >= 4 } -func (x USAddress) Kind() pd1.Kind { - return pd1.Kind_Map +func (x USAddress) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x USAddress) LookupByString(key string) (pd1.Node, error) { +func (x USAddress) LookupByString(key string) (pd3.Node, error) { switch key { - case "street": + case "street": return x.Street.Node(), nil - case "city": + case "city": return x.City.Node(), nil - case "state": + case "state": return x.State.Node(), nil - case "zip": + case "zip": return x.ZIP.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x USAddress) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) LookupByIndex(idx int64) (pd1.Node, error) { +func (x USAddress) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Street.Node(), nil - case 1: + case 1: return x.City.Node(), nil - case 2: + case 2: return x.State.Node(), nil - case 3: + case 3: return x.ZIP.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x USAddress) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "street": + case "0", "street": return x.Street.Node(), nil - case "1", "city": + case "1", "city": return x.City.Node(), nil - case "2", "state": + case "2", "state": return x.State.Node(), nil - case "3", "zip": + case "3", "zip": return x.ZIP.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) MapIterator() pd1.MapIterator { +func (x USAddress) MapIterator() pd3.MapIterator { return &USAddress_MapIterator{-1, &x} } -func (x USAddress) ListIterator() pd1.ListIterator { +func (x USAddress) ListIterator() pd3.ListIterator { return nil } @@ -2065,30 +2100,30 @@ func (x USAddress) IsNull() bool { } func (x USAddress) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x USAddress) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x USAddress) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x USAddress) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x USAddress) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x USAddress) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x USAddress) Prototype() pd1.NodePrototype { +func (x USAddress) Prototype() pd3.NodePrototype { return nil } @@ -2096,49 +2131,49 @@ func (x USAddress) Prototype() pd1.NodePrototype { type StateCA struct{} -func (StateCA) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_String { - return pd2.ErrNA +func (StateCA) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_String { + return pd1.ErrNA } v, err := n.AsString() if err != nil { return err } if v != "CA" { - return pd2.ErrNA + return pd1.ErrNA } return nil } -func (v StateCA) Node() pd1.Node { +func (v StateCA) Node() pd3.Node { return v } -func (StateCA) Kind() pd1.Kind { - return pd1.Kind_String +func (StateCA) Kind() pd3.Kind { + return pd3.Kind_String } -func (StateCA) LookupByString(string) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateCA) LookupByString(string) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (StateCA) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateCA) LookupByNode(key pd3.Node) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (StateCA) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateCA) LookupByIndex(idx int64) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (StateCA) LookupBySegment(_ pd1.PathSegment) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateCA) LookupBySegment(_ pd3.PathSegment) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (StateCA) MapIterator() pd1.MapIterator { +func (StateCA) MapIterator() pd3.MapIterator { return nil } -func (StateCA) ListIterator() pd1.ListIterator { +func (StateCA) ListIterator() pd3.ListIterator { return nil } @@ -2155,15 +2190,15 @@ func (StateCA) IsNull() bool { } func (v StateCA) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (StateCA) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (StateCA) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (StateCA) AsString() (string, error) { @@ -2171,14 +2206,14 @@ func (StateCA) AsString() (string, error) { } func (StateCA) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (StateCA) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (StateCA) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (StateCA) Prototype() pd1.NodePrototype { +func (StateCA) Prototype() pd3.NodePrototype { return nil } @@ -2186,49 +2221,49 @@ func (StateCA) Prototype() pd1.NodePrototype { type StateNY struct{} -func (StateNY) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_String { - return pd2.ErrNA +func (StateNY) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_String { + return pd1.ErrNA } v, err := n.AsString() if err != nil { return err } if v != "NY" { - return pd2.ErrNA + return pd1.ErrNA } return nil } -func (v StateNY) Node() pd1.Node { +func (v StateNY) Node() pd3.Node { return v } -func (StateNY) Kind() pd1.Kind { - return pd1.Kind_String +func (StateNY) Kind() pd3.Kind { + return pd3.Kind_String } -func (StateNY) LookupByString(string) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateNY) LookupByString(string) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (StateNY) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateNY) LookupByNode(key pd3.Node) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (StateNY) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateNY) LookupByIndex(idx int64) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (StateNY) LookupBySegment(_ pd1.PathSegment) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateNY) LookupBySegment(_ pd3.PathSegment) (pd3.Node, error) { + return nil, pd1.ErrNA } -func (StateNY) MapIterator() pd1.MapIterator { +func (StateNY) MapIterator() pd3.MapIterator { return nil } -func (StateNY) ListIterator() pd1.ListIterator { +func (StateNY) ListIterator() pd3.ListIterator { return nil } @@ -2245,15 +2280,15 @@ func (StateNY) IsNull() bool { } func (v StateNY) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (StateNY) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (StateNY) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (StateNY) AsString() (string, error) { @@ -2261,50 +2296,51 @@ func (StateNY) AsString() (string, error) { } func (StateNY) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (StateNY) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (StateNY) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (StateNY) Prototype() pd1.NodePrototype { +func (StateNY) Prototype() pd3.NodePrototype { return nil } // -- protocol type State -- type State struct { - CA *StateCA - NY *StateNY - Other *pd2.String + CA *StateCA + NY *StateNY + Other *pd1.String + } -func (x *State) Parse(n pd1.Node) error { +func (x *State) Parse(n pd3.Node) error { *x = State{} + + var CA StateCA + if err := CA.Parse(n); err == nil { + x.CA = &CA + return nil + } + + var NY StateNY + if err := NY.Parse(n); err == nil { + x.NY = &NY + return nil + } + + var Other pd1.String + if err := Other.Parse(n); err == nil { + x.Other = &Other + return nil + } - var CA StateCA - if err := CA.Parse(n); err == nil { - x.CA = &CA - return nil - } - - var NY StateNY - if err := NY.Parse(n); err == nil { - x.NY = &NY - return nil - } - - var Other pd2.String - if err := Other.Parse(n); err == nil { - x.Other = &Other - return nil - } - - return pd3.Errorf("no union cases parses") + return pd2.Errorf("no union cases parses") } -func (x State) Node() pd1.Node { +func (x State) Node() pd3.Node { if x.CA != nil { return x.CA } @@ -2320,306 +2356,211 @@ func (x State) Node() pd1.Node { // proxy Node methods to active case -func (x State) Kind() pd1.Kind { - if x.CA != nil { - return x.CA.Kind() - } - if x.NY != nil { - return x.NY.Kind() - } - if x.Other != nil { - return x.Other.Kind() - } +func (x State) Kind() pd3.Kind { + if x.CA != nil { return x.CA.Kind() } + if x.NY != nil { return x.NY.Kind() } + if x.Other != nil { return x.Other.Kind() } - return pd1.Kind_Invalid + return pd3.Kind_Invalid } -func (x State) LookupByString(key string) (pd1.Node, error) { - if x.CA != nil { - return x.CA.LookupByString(key) - } - if x.NY != nil { - return x.NY.LookupByString(key) - } - if x.Other != nil { - return x.Other.LookupByString(key) - } +func (x State) LookupByString(key string) (pd3.Node, error) { + if x.CA != nil { return x.CA.LookupByString(key) } + if x.NY != nil { return x.NY.LookupByString(key) } + if x.Other != nil { return x.Other.LookupByString(key) } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x State) LookupByNode(key pd1.Node) (pd1.Node, error) { - if x.CA != nil { - return x.CA.LookupByNode(key) - } - if x.NY != nil { - return x.NY.LookupByNode(key) - } - if x.Other != nil { - return x.Other.LookupByNode(key) - } +func (x State) LookupByNode(key pd3.Node) (pd3.Node, error) { + if x.CA != nil { return x.CA.LookupByNode(key) } + if x.NY != nil { return x.NY.LookupByNode(key) } + if x.Other != nil { return x.Other.LookupByNode(key) } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x State) LookupByIndex(idx int64) (pd1.Node, error) { - if x.CA != nil { - return x.CA.LookupByIndex(idx) - } - if x.NY != nil { - return x.NY.LookupByIndex(idx) - } - if x.Other != nil { - return x.Other.LookupByIndex(idx) - } +func (x State) LookupByIndex(idx int64) (pd3.Node, error) { + if x.CA != nil { return x.CA.LookupByIndex(idx) } + if x.NY != nil { return x.NY.LookupByIndex(idx) } + if x.Other != nil { return x.Other.LookupByIndex(idx) } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x State) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { - if x.CA != nil { - return x.CA.LookupBySegment(seg) - } - if x.NY != nil { - return x.NY.LookupBySegment(seg) - } - if x.Other != nil { - return x.Other.LookupBySegment(seg) - } +func (x State) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { + if x.CA != nil { return x.CA.LookupBySegment(seg) } + if x.NY != nil { return x.NY.LookupBySegment(seg) } + if x.Other != nil { return x.Other.LookupBySegment(seg) } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x State) MapIterator() pd1.MapIterator { - if x.CA != nil { - return x.CA.MapIterator() - } - if x.NY != nil { - return x.NY.MapIterator() - } - if x.Other != nil { - return x.Other.MapIterator() - } +func (x State) MapIterator() pd3.MapIterator { + if x.CA != nil { return x.CA.MapIterator() } + if x.NY != nil { return x.NY.MapIterator() } + if x.Other != nil { return x.Other.MapIterator() } return nil } -func (x State) ListIterator() pd1.ListIterator { - if x.CA != nil { - return x.CA.ListIterator() - } - if x.NY != nil { - return x.NY.ListIterator() - } - if x.Other != nil { - return x.Other.ListIterator() - } +func (x State) ListIterator() pd3.ListIterator { + if x.CA != nil { return x.CA.ListIterator() } + if x.NY != nil { return x.NY.ListIterator() } + if x.Other != nil { return x.Other.ListIterator() } return nil } func (x State) Length() int64 { - if x.CA != nil { - return x.CA.Length() - } - if x.NY != nil { - return x.NY.Length() - } - if x.Other != nil { - return x.Other.Length() - } + if x.CA != nil { return x.CA.Length() } + if x.NY != nil { return x.NY.Length() } + if x.Other != nil { return x.Other.Length() } return -1 } func (x State) IsAbsent() bool { - if x.CA != nil { - return x.CA.IsAbsent() - } - if x.NY != nil { - return x.NY.IsAbsent() - } - if x.Other != nil { - return x.Other.IsAbsent() - } + if x.CA != nil { return x.CA.IsAbsent() } + if x.NY != nil { return x.NY.IsAbsent() } + if x.Other != nil { return x.Other.IsAbsent() } return false } func (x State) IsNull() bool { - if x.CA != nil { - return x.CA.IsNull() - } - if x.NY != nil { - return x.NY.IsNull() - } - if x.Other != nil { - return x.Other.IsNull() - } + if x.CA != nil { return x.CA.IsNull() } + if x.NY != nil { return x.NY.IsNull() } + if x.Other != nil { return x.Other.IsNull() } return false } func (x State) AsBool() (bool, error) { - if x.CA != nil { - return x.CA.AsBool() - } - if x.NY != nil { - return x.NY.AsBool() - } - if x.Other != nil { - return x.Other.AsBool() - } + if x.CA != nil { return x.CA.AsBool() } + if x.NY != nil { return x.NY.AsBool() } + if x.Other != nil { return x.Other.AsBool() } - return false, pd3.Errorf("no active union case found") + return false, pd2.Errorf("no active union case found") } func (x State) AsInt() (int64, error) { - if x.CA != nil { - return x.CA.AsInt() - } - if x.NY != nil { - return x.NY.AsInt() - } - if x.Other != nil { - return x.Other.AsInt() - } + if x.CA != nil { return x.CA.AsInt() } + if x.NY != nil { return x.NY.AsInt() } + if x.Other != nil { return x.Other.AsInt() } - return 0, pd3.Errorf("no active union case found") + return 0, pd2.Errorf("no active union case found") } func (x State) AsFloat() (float64, error) { - if x.CA != nil { - return x.CA.AsFloat() - } - if x.NY != nil { - return x.NY.AsFloat() - } - if x.Other != nil { - return x.Other.AsFloat() - } + if x.CA != nil { return x.CA.AsFloat() } + if x.NY != nil { return x.NY.AsFloat() } + if x.Other != nil { return x.Other.AsFloat() } - return 0.0, pd3.Errorf("no active union case found") + return 0.0, pd2.Errorf("no active union case found") } func (x State) AsString() (string, error) { - if x.CA != nil { - return x.CA.AsString() - } - if x.NY != nil { - return x.NY.AsString() - } - if x.Other != nil { - return x.Other.AsString() - } + if x.CA != nil { return x.CA.AsString() } + if x.NY != nil { return x.NY.AsString() } + if x.Other != nil { return x.Other.AsString() } - return "", pd3.Errorf("no active union case found") + return "", pd2.Errorf("no active union case found") } func (x State) AsBytes() ([]byte, error) { - if x.CA != nil { - return x.CA.AsBytes() - } - if x.NY != nil { - return x.NY.AsBytes() - } - if x.Other != nil { - return x.Other.AsBytes() - } + if x.CA != nil { return x.CA.AsBytes() } + if x.NY != nil { return x.NY.AsBytes() } + if x.Other != nil { return x.Other.AsBytes() } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x State) AsLink() (pd1.Link, error) { - if x.CA != nil { - return x.CA.AsLink() - } - if x.NY != nil { - return x.NY.AsLink() - } - if x.Other != nil { - return x.Other.AsLink() - } +func (x State) AsLink() (pd3.Link, error) { + if x.CA != nil { return x.CA.AsLink() } + if x.NY != nil { return x.NY.AsLink() } + if x.Other != nil { return x.Other.AsLink() } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x State) Prototype() pd1.NodePrototype { +func (x State) Prototype() pd3.NodePrototype { return nil } - // -- protocol type SKAddress -- type SKAddress struct { - Street pd2.String - City pd2.String - Province pd2.String - PostalCode pd2.Int + Street pd1.String + City pd1.String + Province pd1.String + PostalCode pd1.Int + } -func (x SKAddress) Node() pd1.Node { +func (x SKAddress) Node() pd3.Node { return x } -func (x *SKAddress) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *SKAddress) Parse(n pd3.Node) error { + if n.Kind() != pd3.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ - "street": x.Street.Parse, - "city": x.City.Parse, - "province": x.Province.Parse, + fieldMap := map[string]pd1.ParseFunc{ + "street": x.Street.Parse, + "city": x.City.Parse, + "province": x.Province.Parse, "postal_code": x.PostalCode.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err } else { if k, err := kn.AsString(); err != nil { - return pd3.Errorf("structure map key is not a string") + return pd2.Errorf("structure map key is not a string") } else { _ = vn switch k { - case "street": - if _, notParsed := fieldMap["street"]; !notParsed { - return pd3.Errorf("field %s already parsed", "street") - } - if err := x.Street.Parse(vn); err != nil { - return err - } - delete(fieldMap, "street") - case "city": - if _, notParsed := fieldMap["city"]; !notParsed { - return pd3.Errorf("field %s already parsed", "city") - } - if err := x.City.Parse(vn); err != nil { - return err - } - delete(fieldMap, "city") - case "province": - if _, notParsed := fieldMap["province"]; !notParsed { - return pd3.Errorf("field %s already parsed", "province") - } - if err := x.Province.Parse(vn); err != nil { - return err - } - delete(fieldMap, "province") - case "postal_code": - if _, notParsed := fieldMap["postal_code"]; !notParsed { - return pd3.Errorf("field %s already parsed", "postal_code") - } - if err := x.PostalCode.Parse(vn); err != nil { - return err - } - delete(fieldMap, "postal_code") + case "street": + if _, notParsed := fieldMap["street"]; !notParsed { + return pd2.Errorf("field %s already parsed", "street") + } + if err := x.Street.Parse(vn); err != nil { + return err + } + delete(fieldMap, "street") + case "city": + if _, notParsed := fieldMap["city"]; !notParsed { + return pd2.Errorf("field %s already parsed", "city") + } + if err := x.City.Parse(vn); err != nil { + return err + } + delete(fieldMap, "city") + case "province": + if _, notParsed := fieldMap["province"]; !notParsed { + return pd2.Errorf("field %s already parsed", "province") + } + if err := x.Province.Parse(vn); err != nil { + return err + } + delete(fieldMap, "province") + case "postal_code": + if _, notParsed := fieldMap["postal_code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "postal_code") + } + if err := x.PostalCode.Parse(vn); err != nil { + return err + } + delete(fieldMap, "postal_code") } } } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd3.Null); err != nil { return err } } @@ -2631,98 +2572,98 @@ type SKAddress_MapIterator struct { s *SKAddress } -func (x *SKAddress_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *SKAddress_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd2.String("street"), x.s.Street.Node(), nil - case 1: - return pd2.String("city"), x.s.City.Node(), nil - case 2: - return pd2.String("province"), x.s.Province.Node(), nil - case 3: - return pd2.String("postal_code"), x.s.PostalCode.Node(), nil + case 0: + return pd1.String("street"), x.s.Street.Node(), nil + case 1: + return pd1.String("city"), x.s.City.Node(), nil + case 2: + return pd1.String("province"), x.s.Province.Node(), nil + case 3: + return pd1.String("postal_code"), x.s.PostalCode.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *SKAddress_MapIterator) Done() bool { - return x.i+1 >= 4 + return x.i + 1 >= 4 } -func (x SKAddress) Kind() pd1.Kind { - return pd1.Kind_Map +func (x SKAddress) Kind() pd3.Kind { + return pd3.Kind_Map } -func (x SKAddress) LookupByString(key string) (pd1.Node, error) { +func (x SKAddress) LookupByString(key string) (pd3.Node, error) { switch key { - case "street": + case "street": return x.Street.Node(), nil - case "city": + case "city": return x.City.Node(), nil - case "province": + case "province": return x.Province.Node(), nil - case "postal_code": + case "postal_code": return x.PostalCode.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x SKAddress) LookupByNode(key pd3.Node) (pd3.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd3.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd3.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) LookupByIndex(idx int64) (pd1.Node, error) { +func (x SKAddress) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Street.Node(), nil - case 1: + case 1: return x.City.Node(), nil - case 2: + case 2: return x.Province.Node(), nil - case 3: + case 3: return x.PostalCode.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x SKAddress) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "street": + case "0", "street": return x.Street.Node(), nil - case "1", "city": + case "1", "city": return x.City.Node(), nil - case "2", "province": + case "2", "province": return x.Province.Node(), nil - case "3", "postal_code": + case "3", "postal_code": return x.PostalCode.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) MapIterator() pd1.MapIterator { +func (x SKAddress) MapIterator() pd3.MapIterator { return &SKAddress_MapIterator{-1, &x} } -func (x SKAddress) ListIterator() pd1.ListIterator { +func (x SKAddress) ListIterator() pd3.ListIterator { return nil } @@ -2739,59 +2680,60 @@ func (x SKAddress) IsNull() bool { } func (x SKAddress) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x SKAddress) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x SKAddress) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x SKAddress) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x SKAddress) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x SKAddress) AsLink() (pd3.Link, error) { + return nil, pd1.ErrNA } -func (x SKAddress) Prototype() pd1.NodePrototype { +func (x SKAddress) Prototype() pd3.NodePrototype { return nil } // -- protocol type HelloResponse -- type HelloResponse struct { - English *pd2.String - Korean *pd2.String + English *pd1.String + Korean *pd1.String + } -func (x *HelloResponse) Parse(n pd1.Node) error { +func (x *HelloResponse) Parse(n pd3.Node) error { *x = HelloResponse{} + + var English pd1.String + if err := English.Parse(n); err == nil { + x.English = &English + return nil + } + + var Korean pd1.String + if err := Korean.Parse(n); err == nil { + x.Korean = &Korean + return nil + } - var English pd2.String - if err := English.Parse(n); err == nil { - x.English = &English - return nil - } - - var Korean pd2.String - if err := Korean.Parse(n); err == nil { - x.Korean = &Korean - return nil - } - - return pd3.Errorf("no union cases parses") + return pd2.Errorf("no union cases parses") } -func (x HelloResponse) Node() pd1.Node { +func (x HelloResponse) Node() pd3.Node { if x.English != nil { return x.English } @@ -2804,182 +2746,118 @@ func (x HelloResponse) Node() pd1.Node { // proxy Node methods to active case -func (x HelloResponse) Kind() pd1.Kind { - if x.English != nil { - return x.English.Kind() - } - if x.Korean != nil { - return x.Korean.Kind() - } +func (x HelloResponse) Kind() pd3.Kind { + if x.English != nil { return x.English.Kind() } + if x.Korean != nil { return x.Korean.Kind() } - return pd1.Kind_Invalid + return pd3.Kind_Invalid } -func (x HelloResponse) LookupByString(key string) (pd1.Node, error) { - if x.English != nil { - return x.English.LookupByString(key) - } - if x.Korean != nil { - return x.Korean.LookupByString(key) - } +func (x HelloResponse) LookupByString(key string) (pd3.Node, error) { + if x.English != nil { return x.English.LookupByString(key) } + if x.Korean != nil { return x.Korean.LookupByString(key) } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x HelloResponse) LookupByNode(key pd1.Node) (pd1.Node, error) { - if x.English != nil { - return x.English.LookupByNode(key) - } - if x.Korean != nil { - return x.Korean.LookupByNode(key) - } +func (x HelloResponse) LookupByNode(key pd3.Node) (pd3.Node, error) { + if x.English != nil { return x.English.LookupByNode(key) } + if x.Korean != nil { return x.Korean.LookupByNode(key) } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x HelloResponse) LookupByIndex(idx int64) (pd1.Node, error) { - if x.English != nil { - return x.English.LookupByIndex(idx) - } - if x.Korean != nil { - return x.Korean.LookupByIndex(idx) - } +func (x HelloResponse) LookupByIndex(idx int64) (pd3.Node, error) { + if x.English != nil { return x.English.LookupByIndex(idx) } + if x.Korean != nil { return x.Korean.LookupByIndex(idx) } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x HelloResponse) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { - if x.English != nil { - return x.English.LookupBySegment(seg) - } - if x.Korean != nil { - return x.Korean.LookupBySegment(seg) - } +func (x HelloResponse) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { + if x.English != nil { return x.English.LookupBySegment(seg) } + if x.Korean != nil { return x.Korean.LookupBySegment(seg) } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x HelloResponse) MapIterator() pd1.MapIterator { - if x.English != nil { - return x.English.MapIterator() - } - if x.Korean != nil { - return x.Korean.MapIterator() - } +func (x HelloResponse) MapIterator() pd3.MapIterator { + if x.English != nil { return x.English.MapIterator() } + if x.Korean != nil { return x.Korean.MapIterator() } return nil } -func (x HelloResponse) ListIterator() pd1.ListIterator { - if x.English != nil { - return x.English.ListIterator() - } - if x.Korean != nil { - return x.Korean.ListIterator() - } +func (x HelloResponse) ListIterator() pd3.ListIterator { + if x.English != nil { return x.English.ListIterator() } + if x.Korean != nil { return x.Korean.ListIterator() } return nil } func (x HelloResponse) Length() int64 { - if x.English != nil { - return x.English.Length() - } - if x.Korean != nil { - return x.Korean.Length() - } + if x.English != nil { return x.English.Length() } + if x.Korean != nil { return x.Korean.Length() } return -1 } func (x HelloResponse) IsAbsent() bool { - if x.English != nil { - return x.English.IsAbsent() - } - if x.Korean != nil { - return x.Korean.IsAbsent() - } + if x.English != nil { return x.English.IsAbsent() } + if x.Korean != nil { return x.Korean.IsAbsent() } return false } func (x HelloResponse) IsNull() bool { - if x.English != nil { - return x.English.IsNull() - } - if x.Korean != nil { - return x.Korean.IsNull() - } + if x.English != nil { return x.English.IsNull() } + if x.Korean != nil { return x.Korean.IsNull() } return false } func (x HelloResponse) AsBool() (bool, error) { - if x.English != nil { - return x.English.AsBool() - } - if x.Korean != nil { - return x.Korean.AsBool() - } + if x.English != nil { return x.English.AsBool() } + if x.Korean != nil { return x.Korean.AsBool() } - return false, pd3.Errorf("no active union case found") + return false, pd2.Errorf("no active union case found") } func (x HelloResponse) AsInt() (int64, error) { - if x.English != nil { - return x.English.AsInt() - } - if x.Korean != nil { - return x.Korean.AsInt() - } + if x.English != nil { return x.English.AsInt() } + if x.Korean != nil { return x.Korean.AsInt() } - return 0, pd3.Errorf("no active union case found") + return 0, pd2.Errorf("no active union case found") } func (x HelloResponse) AsFloat() (float64, error) { - if x.English != nil { - return x.English.AsFloat() - } - if x.Korean != nil { - return x.Korean.AsFloat() - } + if x.English != nil { return x.English.AsFloat() } + if x.Korean != nil { return x.Korean.AsFloat() } - return 0.0, pd3.Errorf("no active union case found") + return 0.0, pd2.Errorf("no active union case found") } func (x HelloResponse) AsString() (string, error) { - if x.English != nil { - return x.English.AsString() - } - if x.Korean != nil { - return x.Korean.AsString() - } + if x.English != nil { return x.English.AsString() } + if x.Korean != nil { return x.Korean.AsString() } - return "", pd3.Errorf("no active union case found") + return "", pd2.Errorf("no active union case found") } func (x HelloResponse) AsBytes() ([]byte, error) { - if x.English != nil { - return x.English.AsBytes() - } - if x.Korean != nil { - return x.Korean.AsBytes() - } + if x.English != nil { return x.English.AsBytes() } + if x.Korean != nil { return x.Korean.AsBytes() } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x HelloResponse) AsLink() (pd1.Link, error) { - if x.English != nil { - return x.English.AsLink() - } - if x.Korean != nil { - return x.Korean.AsLink() - } +func (x HelloResponse) AsLink() (pd3.Link, error) { + if x.English != nil { return x.English.AsLink() } + if x.Korean != nil { return x.Korean.AsLink() } - return nil, pd3.Errorf("no active union case found") + return nil, pd2.Errorf("no active union case found") } -func (x HelloResponse) Prototype() pd1.NodePrototype { +func (x HelloResponse) Prototype() pd3.NodePrototype { return nil -} +} \ No newline at end of file diff --git a/test/harness.go b/test/harness.go index 468cac0..a53cda5 100644 --- a/test/harness.go +++ b/test/harness.go @@ -3,7 +3,6 @@ package test import ( "bytes" "fmt" - "io/ioutil" "os" "os/exec" "path" @@ -45,7 +44,7 @@ require ( github.com/ipfs/go-cid v0.0.4 ) ` - if err := ioutil.WriteFile(path.Join(dir, "go.mod"), []byte(goModSrc), 0644); err != nil { + if err := os.WriteFile(path.Join(dir, "go.mod"), []byte(goModSrc), 0644); err != nil { t.Fatalf("creating go.mod (%v)", err) } @@ -99,7 +98,7 @@ var ( %s ` - if err := ioutil.WriteFile(path.Join(dir, "edelweiss_test.go"), []byte(fmt.Sprintf(testGoSrc, testSrc)), 0644); err != nil { + if err := os.WriteFile(path.Join(dir, "edelweiss_test.go"), []byte(fmt.Sprintf(testGoSrc, testSrc)), 0644); err != nil { t.Fatalf("creating test.go (%v)", err) } From ac6cb7d89ad9734c2d41255a9f1293259cafbda0 Mon Sep 17 00:00:00 2001 From: galargh Date: Thu, 1 Sep 2022 17:36:03 +0200 Subject: [PATCH 2/4] chore: run go fmt --- blueprints/values/inductive.go | 2 +- blueprints/values/structure.go | 4 +- blueprints/values/union.go | 2 +- .../gen-routing-api/proto/proto_edelweiss.go | 529 +++++----- .../api/proto/proto_edelweiss.go | 934 ++++++++++-------- 5 files changed, 771 insertions(+), 700 deletions(-) diff --git a/blueprints/values/inductive.go b/blueprints/values/inductive.go index cd99174..12d6c3b 100644 --- a/blueprints/values/inductive.go +++ b/blueprints/values/inductive.go @@ -48,7 +48,7 @@ func (x *GoInductiveImpl) GoDef() cg.Blueprint { for i := range cases { caseDecls[i] = cg.T{ Data: caseData[i], - Src: " {{.CaseName}} *{{.CaseType}}\n", + Src: " {{.CaseName}} *{{.CaseType}}\n", } } // build case parse cases diff --git a/blueprints/values/structure.go b/blueprints/values/structure.go index e74ff40..47e865c 100644 --- a/blueprints/values/structure.go +++ b/blueprints/values/structure.go @@ -53,7 +53,7 @@ func (x *GoStructureImpl) GoDef() cg.Blueprint { for i := range fields { fieldDecls[i] = cg.T{ Data: fieldData[i], - Src: " {{.FieldName}} {{.FieldType}}\n", + Src: " {{.FieldName}} {{.FieldType}}\n", } } // build field parse cases @@ -62,7 +62,7 @@ func (x *GoStructureImpl) GoDef() cg.Blueprint { for i := range fields { fieldParseMapCases[i] = cg.T{ Data: fieldData[i], - Src: " {{.FieldNameString}}: x.{{.FieldName}}.Parse,\n", + Src: " {{.FieldNameString}}: x.{{.FieldName}}.Parse,\n", } fieldParseCases[i] = cg.T{ Data: fieldData[i], diff --git a/blueprints/values/union.go b/blueprints/values/union.go index f19c46a..7d7408d 100644 --- a/blueprints/values/union.go +++ b/blueprints/values/union.go @@ -47,7 +47,7 @@ func (x *GoUnionImpl) GoDef() cg.Blueprint { for i := range cases { caseDecls[i] = cg.T{ Data: caseData[i], - Src: " {{.CaseName}} *{{.CaseType}}\n", + Src: " {{.CaseName}} *{{.CaseType}}\n", } } // build cases for Node() method diff --git a/examples/gen-routing-api/proto/proto_edelweiss.go b/examples/gen-routing-api/proto/proto_edelweiss.go index 3bc6f48..69085f9 100644 --- a/examples/gen-routing-api/proto/proto_edelweiss.go +++ b/examples/gen-routing-api/proto/proto_edelweiss.go @@ -2,28 +2,26 @@ package proto -import( - pd1 "github.com/ipld/edelweiss/values" - pd2 "fmt" - pd3 "github.com/ipld/go-ipld-prime/datamodel" - pd4 "net/http" - pd5 "github.com/ipfs/go-log/v2" +import ( pd6 "bytes" pd7 "context" - pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" pd9 "errors" - pd10 "io" + pd2 "fmt" + pd5 "github.com/ipfs/go-log/v2" + pd13 "github.com/ipld/edelweiss/services" + pd1 "github.com/ipld/edelweiss/values" pd11 "github.com/ipld/go-ipld-prime" + pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd10 "io" + pd4 "net/http" pd12 "net/url" - pd13 "github.com/ipld/edelweiss/services" pd14 "sync" ) - // -- protocol type DelegatedRouting_IdentifyArg -- type DelegatedRouting_IdentifyArg struct { - } func (x DelegatedRouting_IdentifyArg) Node() pd3.Node { @@ -35,9 +33,7 @@ func (x *DelegatedRouting_IdentifyArg) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ - - } + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -74,7 +70,7 @@ func (x *DelegatedRouting_IdentifyArg_MapIterator) Next() (key pd3.Node, value p } func (x *DelegatedRouting_IdentifyArg_MapIterator) Done() bool { - return x.i + 1 >= 0 + return x.i+1 >= 0 } func (x DelegatedRouting_IdentifyArg) Kind() pd3.Kind { @@ -291,11 +287,11 @@ func (iter *AnonList1_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList1_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type DelegatedRouting_IdentifyResult -- type DelegatedRouting_IdentifyResult struct { - Methods AnonList1 - + Methods AnonList1 } func (x DelegatedRouting_IdentifyResult) Node() pd3.Node { @@ -308,8 +304,7 @@ func (x *DelegatedRouting_IdentifyResult) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Methods": x.Methods.Parse, - + "Methods": x.Methods.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -320,14 +315,14 @@ func (x *DelegatedRouting_IdentifyResult) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Methods": - if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Methods") - } - if err := x.Methods.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Methods") + case "Methods": + if _, notParsed := fieldMap["Methods"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Methods") + } + if err := x.Methods.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Methods") } } @@ -349,15 +344,15 @@ type DelegatedRouting_IdentifyResult_MapIterator struct { func (x *DelegatedRouting_IdentifyResult_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Methods"), x.s.Methods.Node(), nil + case 0: + return pd1.String("Methods"), x.s.Methods.Node(), nil } return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_IdentifyResult_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x DelegatedRouting_IdentifyResult) Kind() pd3.Kind { @@ -366,7 +361,7 @@ func (x DelegatedRouting_IdentifyResult) Kind() pd3.Kind { func (x DelegatedRouting_IdentifyResult) LookupByString(key string) (pd3.Node, error) { switch key { - case "Methods": + case "Methods": return x.Methods.Node(), nil } @@ -393,7 +388,7 @@ func (x DelegatedRouting_IdentifyResult) LookupByNode(key pd3.Node) (pd3.Node, e func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Methods.Node(), nil } @@ -402,7 +397,7 @@ func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, err func (x DelegatedRouting_IdentifyResult) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Methods": + case "0", "Methods": return x.Methods.Node(), nil } @@ -460,8 +455,7 @@ func (x DelegatedRouting_IdentifyResult) Prototype() pd3.NodePrototype { // -- protocol type DelegatedRouting_Error -- type DelegatedRouting_Error struct { - Code pd1.String - + Code pd1.String } func (x DelegatedRouting_Error) Node() pd3.Node { @@ -474,8 +468,7 @@ func (x *DelegatedRouting_Error) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Code": x.Code.Parse, - + "Code": x.Code.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -486,14 +479,14 @@ func (x *DelegatedRouting_Error) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Code": - if _, notParsed := fieldMap["Code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Code") - } - if err := x.Code.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Code") + case "Code": + if _, notParsed := fieldMap["Code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Code") + } + if err := x.Code.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Code") } } @@ -515,15 +508,15 @@ type DelegatedRouting_Error_MapIterator struct { func (x *DelegatedRouting_Error_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Code"), x.s.Code.Node(), nil + case 0: + return pd1.String("Code"), x.s.Code.Node(), nil } return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_Error_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x DelegatedRouting_Error) Kind() pd3.Kind { @@ -532,7 +525,7 @@ func (x DelegatedRouting_Error) Kind() pd3.Kind { func (x DelegatedRouting_Error) LookupByString(key string) (pd3.Node, error) { switch key { - case "Code": + case "Code": return x.Code.Node(), nil } @@ -559,7 +552,7 @@ func (x DelegatedRouting_Error) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Code.Node(), nil } @@ -568,7 +561,7 @@ func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd3.Node, error) { func (x DelegatedRouting_Error) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Code": + case "0", "Code": return x.Code.Node(), nil } @@ -626,10 +619,8 @@ func (x DelegatedRouting_Error) Prototype() pd3.NodePrototype { // -- protocol type AnonInductive4 -- type AnonInductive4 struct { - Identify *DelegatedRouting_IdentifyArg - GetP2PProvide *GetP2PProvideRequest - - + Identify *DelegatedRouting_IdentifyArg + GetP2PProvide *GetP2PProvideRequest } func (x *AnonInductive4) Parse(n pd3.Node) error { @@ -662,7 +653,6 @@ func (x *AnonInductive4) Parse(n pd3.Node) error { x.GetP2PProvide = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -680,12 +670,11 @@ func (x *AnonInductive4_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil - case x.s.GetP2PProvide != nil: + case x.s.GetP2PProvide != nil: return pd1.String("GetP2PProvideRequest"), x.s.GetP2PProvide.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -706,12 +695,11 @@ func (x AnonInductive4) Kind() pd3.Kind { func (x AnonInductive4) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyRequest": + case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil - case x.GetP2PProvide != nil && key == "GetP2PProvideRequest": + case x.GetP2PProvide != nil && key == "GetP2PProvideRequest": return x.GetP2PProvide.Node(), nil - } return nil, pd1.ErrNA } @@ -733,12 +721,11 @@ func (x AnonInductive4) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive4) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyRequest": + case "IdentifyRequest": return x.Identify.Node(), nil - case "GetP2PProvideRequest": + case "GetP2PProvideRequest": return x.GetP2PProvide.Node(), nil - } return nil, pd1.ErrNA } @@ -790,14 +777,13 @@ func (x AnonInductive4) AsLink() (pd3.Link, error) { func (x AnonInductive4) Prototype() pd3.NodePrototype { return nil } + // -- protocol type AnonInductive5 -- type AnonInductive5 struct { - Identify *DelegatedRouting_IdentifyResult - GetP2PProvide *GetP2PProvideResponse - Error *DelegatedRouting_Error - - + Identify *DelegatedRouting_IdentifyResult + GetP2PProvide *GetP2PProvideResponse + Error *DelegatedRouting_Error } func (x *AnonInductive5) Parse(n pd3.Node) error { @@ -837,7 +823,6 @@ func (x *AnonInductive5) Parse(n pd3.Node) error { x.Error = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -855,14 +840,13 @@ func (x *AnonInductive5_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil - case x.s.GetP2PProvide != nil: + case x.s.GetP2PProvide != nil: return pd1.String("GetP2PProvideResponse"), x.s.GetP2PProvide.Node(), nil - case x.s.Error != nil: + case x.s.Error != nil: return pd1.String("Error"), x.s.Error.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -883,14 +867,13 @@ func (x AnonInductive5) Kind() pd3.Kind { func (x AnonInductive5) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyResponse": + case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil - case x.GetP2PProvide != nil && key == "GetP2PProvideResponse": + case x.GetP2PProvide != nil && key == "GetP2PProvideResponse": return x.GetP2PProvide.Node(), nil - case x.Error != nil && key == "Error": + case x.Error != nil && key == "Error": return x.Error.Node(), nil - } return nil, pd1.ErrNA } @@ -912,14 +895,13 @@ func (x AnonInductive5) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive5) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyResponse": + case "IdentifyResponse": return x.Identify.Node(), nil - case "GetP2PProvideResponse": + case "GetP2PProvideResponse": return x.GetP2PProvide.Node(), nil - case "Error": + case "Error": return x.Error.Node(), nil - } return nil, pd1.ErrNA } @@ -971,22 +953,19 @@ func (x AnonInductive5) AsLink() (pd3.Link, error) { func (x AnonInductive5) Prototype() pd3.NodePrototype { return nil } + var logger_client_DelegatedRouting = pd5.Logger("service/client/delegatedrouting") type DelegatedRouting_Client interface { + Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) -Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) + GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) -GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) - - -Identify_Async(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) - -GetP2PProvide_Async(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) + Identify_Async(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) + GetP2PProvide_Async(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) } - type DelegatedRouting_Identify_AsyncResult struct { Resp *DelegatedRouting_IdentifyResult Err error @@ -997,13 +976,12 @@ type DelegatedRouting_GetP2PProvide_AsyncResult struct { Err error } - type DelegatedRouting_ClientOption func(*client_DelegatedRouting) error type client_DelegatedRouting struct { - httpClient *pd4.Client - endpoint *pd12.URL - ulk pd14.Mutex + httpClient *pd4.Client + endpoint *pd12.URL + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } @@ -1028,8 +1006,6 @@ func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_Clien return c, nil } - - func (c *client_DelegatedRouting) Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1128,8 +1104,8 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd7.Context, ch chan<- De defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1162,14 +1138,13 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd7.Context, ch chan<- De } select { - case <- ctx.Done(): - return - case ch <- out: + case <-ctx.Done(): + return + case ch <- out: } } } - func (c *client_DelegatedRouting) GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1268,8 +1243,8 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd7.Context, ch chan defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1302,18 +1277,16 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd7.Context, ch chan } select { - case <- ctx.Done(): - return - case ch <- out: + case <-ctx.Done(): + return + case ch <- out: } } } - var logger_server_DelegatedRouting = pd5.Logger("service/server/delegatedrouting") type DelegatedRouting_Server interface { - GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) } @@ -1370,9 +1343,9 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{ Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())} } + env = &AnonInductive5{Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())}} } else { - env = &AnonInductive5{ GetP2PProvide: resp.Resp } + env = &AnonInductive5{GetP2PProvide: resp.Resp} } var buf pd6.Buffer if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { @@ -1387,14 +1360,12 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } } - case env.Identify != nil: var env *AnonInductive5 env = &AnonInductive5{ Identify: &DelegatedRouting_IdentifyResult{ Methods: []pd1.String{ "GetP2PProvide", - }, }, } @@ -1537,11 +1508,11 @@ func (iter *AnonList7_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList7_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type GetP2PProvideRequest -- type GetP2PProvideRequest struct { - Keys AnonList7 - + Keys AnonList7 } func (x GetP2PProvideRequest) Node() pd3.Node { @@ -1554,8 +1525,7 @@ func (x *GetP2PProvideRequest) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Keys": x.Keys.Parse, - + "Keys": x.Keys.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1566,14 +1536,14 @@ func (x *GetP2PProvideRequest) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Keys": - if _, notParsed := fieldMap["Keys"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Keys") - } - if err := x.Keys.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Keys") + case "Keys": + if _, notParsed := fieldMap["Keys"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Keys") + } + if err := x.Keys.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Keys") } } @@ -1595,15 +1565,15 @@ type GetP2PProvideRequest_MapIterator struct { func (x *GetP2PProvideRequest_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Keys"), x.s.Keys.Node(), nil + case 0: + return pd1.String("Keys"), x.s.Keys.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GetP2PProvideRequest_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x GetP2PProvideRequest) Kind() pd3.Kind { @@ -1612,7 +1582,7 @@ func (x GetP2PProvideRequest) Kind() pd3.Kind { func (x GetP2PProvideRequest) LookupByString(key string) (pd3.Node, error) { switch key { - case "Keys": + case "Keys": return x.Keys.Node(), nil } @@ -1639,7 +1609,7 @@ func (x GetP2PProvideRequest) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Keys.Node(), nil } @@ -1648,7 +1618,7 @@ func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd3.Node, error) { func (x GetP2PProvideRequest) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Keys": + case "0", "Keys": return x.Keys.Node(), nil } @@ -1826,11 +1796,11 @@ func (iter *AnonList9_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList9_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type GetP2PProvideResponse -- type GetP2PProvideResponse struct { - ProvidersByKey AnonList9 - + ProvidersByKey AnonList9 } func (x GetP2PProvideResponse) Node() pd3.Node { @@ -1843,8 +1813,7 @@ func (x *GetP2PProvideResponse) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "ProvidersByKey": x.ProvidersByKey.Parse, - + "ProvidersByKey": x.ProvidersByKey.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1855,14 +1824,14 @@ func (x *GetP2PProvideResponse) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "ProvidersByKey": - if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { - return pd2.Errorf("field %s already parsed", "ProvidersByKey") - } - if err := x.ProvidersByKey.Parse(vn); err != nil { - return err - } - delete(fieldMap, "ProvidersByKey") + case "ProvidersByKey": + if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { + return pd2.Errorf("field %s already parsed", "ProvidersByKey") + } + if err := x.ProvidersByKey.Parse(vn); err != nil { + return err + } + delete(fieldMap, "ProvidersByKey") } } @@ -1884,15 +1853,15 @@ type GetP2PProvideResponse_MapIterator struct { func (x *GetP2PProvideResponse_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil + case 0: + return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GetP2PProvideResponse_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x GetP2PProvideResponse) Kind() pd3.Kind { @@ -1901,7 +1870,7 @@ func (x GetP2PProvideResponse) Kind() pd3.Kind { func (x GetP2PProvideResponse) LookupByString(key string) (pd3.Node, error) { switch key { - case "ProvidersByKey": + case "ProvidersByKey": return x.ProvidersByKey.Node(), nil } @@ -1928,7 +1897,7 @@ func (x GetP2PProvideResponse) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.ProvidersByKey.Node(), nil } @@ -1937,7 +1906,7 @@ func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd3.Node, error) { func (x GetP2PProvideResponse) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "ProvidersByKey": + case "0", "ProvidersByKey": return x.ProvidersByKey.Node(), nil } @@ -1995,9 +1964,8 @@ func (x GetP2PProvideResponse) Prototype() pd3.NodePrototype { // -- protocol type ProvidersByKey -- type ProvidersByKey struct { - Key Multihash - Provider Provider - + Key Multihash + Provider Provider } func (x ProvidersByKey) Node() pd3.Node { @@ -2010,9 +1978,8 @@ func (x *ProvidersByKey) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Key": x.Key.Parse, + "Key": x.Key.Parse, "Provider": x.Provider.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2023,22 +1990,22 @@ func (x *ProvidersByKey) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Key": - if _, notParsed := fieldMap["Key"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Key") - } - if err := x.Key.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Key") - case "Provider": - if _, notParsed := fieldMap["Provider"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Provider") - } - if err := x.Provider.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Provider") + case "Key": + if _, notParsed := fieldMap["Key"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Key") + } + if err := x.Key.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Key") + case "Provider": + if _, notParsed := fieldMap["Provider"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Provider") + } + if err := x.Provider.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Provider") } } @@ -2060,17 +2027,17 @@ type ProvidersByKey_MapIterator struct { func (x *ProvidersByKey_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Key"), x.s.Key.Node(), nil - case 1: - return pd1.String("Provider"), x.s.Provider.Node(), nil + case 0: + return pd1.String("Key"), x.s.Key.Node(), nil + case 1: + return pd1.String("Provider"), x.s.Provider.Node(), nil } return nil, nil, pd1.ErrNA } func (x *ProvidersByKey_MapIterator) Done() bool { - return x.i + 1 >= 2 + return x.i+1 >= 2 } func (x ProvidersByKey) Kind() pd3.Kind { @@ -2079,9 +2046,9 @@ func (x ProvidersByKey) Kind() pd3.Kind { func (x ProvidersByKey) LookupByString(key string) (pd3.Node, error) { switch key { - case "Key": + case "Key": return x.Key.Node(), nil - case "Provider": + case "Provider": return x.Provider.Node(), nil } @@ -2108,9 +2075,9 @@ func (x ProvidersByKey) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x ProvidersByKey) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Key.Node(), nil - case 1: + case 1: return x.Provider.Node(), nil } @@ -2119,9 +2086,9 @@ func (x ProvidersByKey) LookupByIndex(idx int64) (pd3.Node, error) { func (x ProvidersByKey) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Key": + case "0", "Key": return x.Key.Node(), nil - case "1", "Provider": + case "1", "Provider": return x.Provider.Node(), nil } @@ -2179,8 +2146,7 @@ func (x ProvidersByKey) Prototype() pd3.NodePrototype { // -- protocol type Multihash -- type Multihash struct { - Bytes pd1.Bytes - + Bytes pd1.Bytes } func (x Multihash) Node() pd3.Node { @@ -2193,8 +2159,7 @@ func (x *Multihash) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Bytes": x.Bytes.Parse, - + "Bytes": x.Bytes.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2205,14 +2170,14 @@ func (x *Multihash) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Bytes": - if _, notParsed := fieldMap["Bytes"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Bytes") - } - if err := x.Bytes.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Bytes") + case "Bytes": + if _, notParsed := fieldMap["Bytes"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Bytes") + } + if err := x.Bytes.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Bytes") } } @@ -2234,15 +2199,15 @@ type Multihash_MapIterator struct { func (x *Multihash_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Bytes"), x.s.Bytes.Node(), nil + case 0: + return pd1.String("Bytes"), x.s.Bytes.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Multihash_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x Multihash) Kind() pd3.Kind { @@ -2251,7 +2216,7 @@ func (x Multihash) Kind() pd3.Kind { func (x Multihash) LookupByString(key string) (pd3.Node, error) { switch key { - case "Bytes": + case "Bytes": return x.Bytes.Node(), nil } @@ -2278,7 +2243,7 @@ func (x Multihash) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Multihash) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Bytes.Node(), nil } @@ -2287,7 +2252,7 @@ func (x Multihash) LookupByIndex(idx int64) (pd3.Node, error) { func (x Multihash) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Bytes": + case "0", "Bytes": return x.Bytes.Node(), nil } @@ -2465,6 +2430,7 @@ func (iter *AnonList13_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList13_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type AnonList14 -- type AnonList14 []TransferProto @@ -2588,12 +2554,12 @@ func (iter *AnonList14_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList14_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type Provider -- type Provider struct { - Nodes AnonList13 - Proto AnonList14 - + Nodes AnonList13 + Proto AnonList14 } func (x Provider) Node() pd3.Node { @@ -2606,9 +2572,8 @@ func (x *Provider) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Nodes": x.Nodes.Parse, + "Nodes": x.Nodes.Parse, "Proto": x.Proto.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2619,22 +2584,22 @@ func (x *Provider) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Nodes": - if _, notParsed := fieldMap["Nodes"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Nodes") - } - if err := x.Nodes.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Nodes") - case "Proto": - if _, notParsed := fieldMap["Proto"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Proto") - } - if err := x.Proto.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Proto") + case "Nodes": + if _, notParsed := fieldMap["Nodes"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Nodes") + } + if err := x.Nodes.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Nodes") + case "Proto": + if _, notParsed := fieldMap["Proto"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Proto") + } + if err := x.Proto.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Proto") } } @@ -2656,17 +2621,17 @@ type Provider_MapIterator struct { func (x *Provider_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Nodes"), x.s.Nodes.Node(), nil - case 1: - return pd1.String("Proto"), x.s.Proto.Node(), nil + case 0: + return pd1.String("Nodes"), x.s.Nodes.Node(), nil + case 1: + return pd1.String("Proto"), x.s.Proto.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Provider_MapIterator) Done() bool { - return x.i + 1 >= 2 + return x.i+1 >= 2 } func (x Provider) Kind() pd3.Kind { @@ -2675,9 +2640,9 @@ func (x Provider) Kind() pd3.Kind { func (x Provider) LookupByString(key string) (pd3.Node, error) { switch key { - case "Nodes": + case "Nodes": return x.Nodes.Node(), nil - case "Proto": + case "Proto": return x.Proto.Node(), nil } @@ -2704,9 +2669,9 @@ func (x Provider) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Provider) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Nodes.Node(), nil - case 1: + case 1: return x.Proto.Node(), nil } @@ -2715,9 +2680,9 @@ func (x Provider) LookupByIndex(idx int64) (pd3.Node, error) { func (x Provider) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Nodes": + case "0", "Nodes": return x.Nodes.Node(), nil - case "1", "Proto": + case "1", "Proto": return x.Proto.Node(), nil } @@ -2775,9 +2740,7 @@ func (x Provider) Prototype() pd3.NodePrototype { // -- protocol type Node -- type Node struct { - Peer *Peer - - + Peer *Peer } func (x *Node) Parse(n pd3.Node) error { @@ -2803,7 +2766,6 @@ func (x *Node) Parse(n pd3.Node) error { x.Peer = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -2821,10 +2783,9 @@ func (x *Node_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { } else { x.done = true switch { - case x.s.Peer != nil: + case x.s.Peer != nil: return pd1.String("Peer"), x.s.Peer.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -2845,10 +2806,9 @@ func (x Node) Kind() pd3.Kind { func (x Node) LookupByString(key string) (pd3.Node, error) { switch { - case x.Peer != nil && key == "Peer": + case x.Peer != nil && key == "Peer": return x.Peer.Node(), nil - } return nil, pd1.ErrNA } @@ -2870,10 +2830,9 @@ func (x Node) LookupByIndex(idx int64) (pd3.Node, error) { func (x Node) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "Peer": + case "Peer": return x.Peer.Node(), nil - } return nil, pd1.ErrNA } @@ -2925,6 +2884,7 @@ func (x Node) AsLink() (pd3.Link, error) { func (x Node) Prototype() pd3.NodePrototype { return nil } + // -- protocol type AnonList17 -- type AnonList17 []pd1.Bytes @@ -3048,12 +3008,12 @@ func (iter *AnonList17_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList17_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type Peer -- type Peer struct { - ID pd1.Bytes - Multiaddresses AnonList17 - + ID pd1.Bytes + Multiaddresses AnonList17 } func (x Peer) Node() pd3.Node { @@ -3066,9 +3026,8 @@ func (x *Peer) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "ID": x.ID.Parse, + "ID": x.ID.Parse, "Multiaddresses": x.Multiaddresses.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -3079,22 +3038,22 @@ func (x *Peer) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "ID": - if _, notParsed := fieldMap["ID"]; !notParsed { - return pd2.Errorf("field %s already parsed", "ID") - } - if err := x.ID.Parse(vn); err != nil { - return err - } - delete(fieldMap, "ID") - case "Multiaddresses": - if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Multiaddresses") - } - if err := x.Multiaddresses.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Multiaddresses") + case "ID": + if _, notParsed := fieldMap["ID"]; !notParsed { + return pd2.Errorf("field %s already parsed", "ID") + } + if err := x.ID.Parse(vn); err != nil { + return err + } + delete(fieldMap, "ID") + case "Multiaddresses": + if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Multiaddresses") + } + if err := x.Multiaddresses.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Multiaddresses") } } @@ -3116,17 +3075,17 @@ type Peer_MapIterator struct { func (x *Peer_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("ID"), x.s.ID.Node(), nil - case 1: - return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil + case 0: + return pd1.String("ID"), x.s.ID.Node(), nil + case 1: + return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Peer_MapIterator) Done() bool { - return x.i + 1 >= 2 + return x.i+1 >= 2 } func (x Peer) Kind() pd3.Kind { @@ -3135,9 +3094,9 @@ func (x Peer) Kind() pd3.Kind { func (x Peer) LookupByString(key string) (pd3.Node, error) { switch key { - case "ID": + case "ID": return x.ID.Node(), nil - case "Multiaddresses": + case "Multiaddresses": return x.Multiaddresses.Node(), nil } @@ -3164,9 +3123,9 @@ func (x Peer) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Peer) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.ID.Node(), nil - case 1: + case 1: return x.Multiaddresses.Node(), nil } @@ -3175,9 +3134,9 @@ func (x Peer) LookupByIndex(idx int64) (pd3.Node, error) { func (x Peer) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "ID": + case "0", "ID": return x.ID.Node(), nil - case "1", "Multiaddresses": + case "1", "Multiaddresses": return x.Multiaddresses.Node(), nil } @@ -3235,9 +3194,7 @@ func (x Peer) Prototype() pd3.NodePrototype { // -- protocol type TransferProto -- type TransferProto struct { - Bitswap *BitswapTransfer - - + Bitswap *BitswapTransfer } func (x *TransferProto) Parse(n pd3.Node) error { @@ -3263,7 +3220,6 @@ func (x *TransferProto) Parse(n pd3.Node) error { x.Bitswap = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -3281,10 +3237,9 @@ func (x *TransferProto_MapIterator) Next() (key pd3.Node, value pd3.Node, err er } else { x.done = true switch { - case x.s.Bitswap != nil: + case x.s.Bitswap != nil: return pd1.String("Bitswap"), x.s.Bitswap.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -3305,10 +3260,9 @@ func (x TransferProto) Kind() pd3.Kind { func (x TransferProto) LookupByString(key string) (pd3.Node, error) { switch { - case x.Bitswap != nil && key == "Bitswap": + case x.Bitswap != nil && key == "Bitswap": return x.Bitswap.Node(), nil - } return nil, pd1.ErrNA } @@ -3330,10 +3284,9 @@ func (x TransferProto) LookupByIndex(idx int64) (pd3.Node, error) { func (x TransferProto) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "Bitswap": + case "Bitswap": return x.Bitswap.Node(), nil - } return nil, pd1.ErrNA } @@ -3385,10 +3338,10 @@ func (x TransferProto) AsLink() (pd3.Link, error) { func (x TransferProto) Prototype() pd3.NodePrototype { return nil } + // -- protocol type BitswapTransfer -- type BitswapTransfer struct { - } func (x BitswapTransfer) Node() pd3.Node { @@ -3400,9 +3353,7 @@ func (x *BitswapTransfer) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ - - } + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -3439,7 +3390,7 @@ func (x *BitswapTransfer_MapIterator) Next() (key pd3.Node, value pd3.Node, err } func (x *BitswapTransfer_MapIterator) Done() bool { - return x.i + 1 >= 0 + return x.i+1 >= 0 } func (x BitswapTransfer) Kind() pd3.Kind { diff --git a/examples/greeting-service/api/proto/proto_edelweiss.go b/examples/greeting-service/api/proto/proto_edelweiss.go index 4a064de..49eb1be 100644 --- a/examples/greeting-service/api/proto/proto_edelweiss.go +++ b/examples/greeting-service/api/proto/proto_edelweiss.go @@ -2,28 +2,26 @@ package proto -import( - pd1 "github.com/ipld/edelweiss/values" - pd2 "fmt" - pd3 "github.com/ipld/go-ipld-prime/datamodel" - pd4 "net/http" - pd5 "github.com/ipfs/go-log/v2" +import ( pd6 "bytes" pd7 "context" - pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" pd9 "errors" - pd10 "io" + pd2 "fmt" + pd5 "github.com/ipfs/go-log/v2" + pd13 "github.com/ipld/edelweiss/services" + pd1 "github.com/ipld/edelweiss/values" pd11 "github.com/ipld/go-ipld-prime" + pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd10 "io" + pd4 "net/http" pd12 "net/url" - pd13 "github.com/ipld/edelweiss/services" pd14 "sync" ) - // -- protocol type GreetingService_IdentifyArg -- type GreetingService_IdentifyArg struct { - } func (x GreetingService_IdentifyArg) Node() pd3.Node { @@ -35,9 +33,7 @@ func (x *GreetingService_IdentifyArg) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ - - } + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -74,7 +70,7 @@ func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd3.Node, value pd } func (x *GreetingService_IdentifyArg_MapIterator) Done() bool { - return x.i + 1 >= 0 + return x.i+1 >= 0 } func (x GreetingService_IdentifyArg) Kind() pd3.Kind { @@ -291,11 +287,11 @@ func (iter *AnonList1_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList1_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type GreetingService_IdentifyResult -- type GreetingService_IdentifyResult struct { - Methods AnonList1 - + Methods AnonList1 } func (x GreetingService_IdentifyResult) Node() pd3.Node { @@ -308,8 +304,7 @@ func (x *GreetingService_IdentifyResult) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Methods": x.Methods.Parse, - + "Methods": x.Methods.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -320,14 +315,14 @@ func (x *GreetingService_IdentifyResult) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Methods": - if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Methods") - } - if err := x.Methods.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Methods") + case "Methods": + if _, notParsed := fieldMap["Methods"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Methods") + } + if err := x.Methods.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Methods") } } @@ -349,15 +344,15 @@ type GreetingService_IdentifyResult_MapIterator struct { func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Methods"), x.s.Methods.Node(), nil + case 0: + return pd1.String("Methods"), x.s.Methods.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GreetingService_IdentifyResult_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x GreetingService_IdentifyResult) Kind() pd3.Kind { @@ -366,7 +361,7 @@ func (x GreetingService_IdentifyResult) Kind() pd3.Kind { func (x GreetingService_IdentifyResult) LookupByString(key string) (pd3.Node, error) { switch key { - case "Methods": + case "Methods": return x.Methods.Node(), nil } @@ -393,7 +388,7 @@ func (x GreetingService_IdentifyResult) LookupByNode(key pd3.Node) (pd3.Node, er func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Methods.Node(), nil } @@ -402,7 +397,7 @@ func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, erro func (x GreetingService_IdentifyResult) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Methods": + case "0", "Methods": return x.Methods.Node(), nil } @@ -460,8 +455,7 @@ func (x GreetingService_IdentifyResult) Prototype() pd3.NodePrototype { // -- protocol type GreetingService_Error -- type GreetingService_Error struct { - Code pd1.String - + Code pd1.String } func (x GreetingService_Error) Node() pd3.Node { @@ -474,8 +468,7 @@ func (x *GreetingService_Error) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Code": x.Code.Parse, - + "Code": x.Code.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -486,14 +479,14 @@ func (x *GreetingService_Error) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Code": - if _, notParsed := fieldMap["Code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Code") - } - if err := x.Code.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Code") + case "Code": + if _, notParsed := fieldMap["Code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Code") + } + if err := x.Code.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Code") } } @@ -515,15 +508,15 @@ type GreetingService_Error_MapIterator struct { func (x *GreetingService_Error_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Code"), x.s.Code.Node(), nil + case 0: + return pd1.String("Code"), x.s.Code.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GreetingService_Error_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x GreetingService_Error) Kind() pd3.Kind { @@ -532,7 +525,7 @@ func (x GreetingService_Error) Kind() pd3.Kind { func (x GreetingService_Error) LookupByString(key string) (pd3.Node, error) { switch key { - case "Code": + case "Code": return x.Code.Node(), nil } @@ -559,7 +552,7 @@ func (x GreetingService_Error) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GreetingService_Error) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Code.Node(), nil } @@ -568,7 +561,7 @@ func (x GreetingService_Error) LookupByIndex(idx int64) (pd3.Node, error) { func (x GreetingService_Error) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Code": + case "0", "Code": return x.Code.Node(), nil } @@ -626,10 +619,8 @@ func (x GreetingService_Error) Prototype() pd3.NodePrototype { // -- protocol type AnonInductive4 -- type AnonInductive4 struct { - Identify *GreetingService_IdentifyArg - Hello *HelloRequest - - + Identify *GreetingService_IdentifyArg + Hello *HelloRequest } func (x *AnonInductive4) Parse(n pd3.Node) error { @@ -662,7 +653,6 @@ func (x *AnonInductive4) Parse(n pd3.Node) error { x.Hello = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -680,12 +670,11 @@ func (x *AnonInductive4_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil - case x.s.Hello != nil: + case x.s.Hello != nil: return pd1.String("HelloRequest"), x.s.Hello.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -706,12 +695,11 @@ func (x AnonInductive4) Kind() pd3.Kind { func (x AnonInductive4) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyRequest": + case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil - case x.Hello != nil && key == "HelloRequest": + case x.Hello != nil && key == "HelloRequest": return x.Hello.Node(), nil - } return nil, pd1.ErrNA } @@ -733,12 +721,11 @@ func (x AnonInductive4) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive4) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyRequest": + case "IdentifyRequest": return x.Identify.Node(), nil - case "HelloRequest": + case "HelloRequest": return x.Hello.Node(), nil - } return nil, pd1.ErrNA } @@ -790,14 +777,13 @@ func (x AnonInductive4) AsLink() (pd3.Link, error) { func (x AnonInductive4) Prototype() pd3.NodePrototype { return nil } + // -- protocol type AnonInductive5 -- type AnonInductive5 struct { - Identify *GreetingService_IdentifyResult - Hello *HelloResponse - Error *GreetingService_Error - - + Identify *GreetingService_IdentifyResult + Hello *HelloResponse + Error *GreetingService_Error } func (x *AnonInductive5) Parse(n pd3.Node) error { @@ -837,7 +823,6 @@ func (x *AnonInductive5) Parse(n pd3.Node) error { x.Error = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -855,14 +840,13 @@ func (x *AnonInductive5_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil - case x.s.Hello != nil: + case x.s.Hello != nil: return pd1.String("HelloResponse"), x.s.Hello.Node(), nil - case x.s.Error != nil: + case x.s.Error != nil: return pd1.String("Error"), x.s.Error.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -883,14 +867,13 @@ func (x AnonInductive5) Kind() pd3.Kind { func (x AnonInductive5) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyResponse": + case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil - case x.Hello != nil && key == "HelloResponse": + case x.Hello != nil && key == "HelloResponse": return x.Hello.Node(), nil - case x.Error != nil && key == "Error": + case x.Error != nil && key == "Error": return x.Error.Node(), nil - } return nil, pd1.ErrNA } @@ -912,14 +895,13 @@ func (x AnonInductive5) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive5) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyResponse": + case "IdentifyResponse": return x.Identify.Node(), nil - case "HelloResponse": + case "HelloResponse": return x.Hello.Node(), nil - case "Error": + case "Error": return x.Error.Node(), nil - } return nil, pd1.ErrNA } @@ -971,22 +953,19 @@ func (x AnonInductive5) AsLink() (pd3.Link, error) { func (x AnonInductive5) Prototype() pd3.NodePrototype { return nil } + var logger_client_GreetingService = pd5.Logger("service/client/greetingservice") type GreetingService_Client interface { + Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) -Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) - -Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) - + Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) -Identify_Async(ctx pd7.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) - -Hello_Async(ctx pd7.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) + Identify_Async(ctx pd7.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) + Hello_Async(ctx pd7.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) } - type GreetingService_Identify_AsyncResult struct { Resp *GreetingService_IdentifyResult Err error @@ -997,13 +976,12 @@ type GreetingService_Hello_AsyncResult struct { Err error } - type GreetingService_ClientOption func(*client_GreetingService) error type client_GreetingService struct { - httpClient *pd4.Client - endpoint *pd12.URL - ulk pd14.Mutex + httpClient *pd4.Client + endpoint *pd12.URL + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } @@ -1028,8 +1006,6 @@ func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientO return c, nil } - - func (c *client_GreetingService) Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1128,8 +1104,8 @@ func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- Gre defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1162,14 +1138,13 @@ func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- Gre } select { - case <- ctx.Done(): - return - case ch <- out: + case <-ctx.Done(): + return + case ch <- out: } } } - func (c *client_GreetingService) Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1268,8 +1243,8 @@ func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- Greeti defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1302,18 +1277,16 @@ func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- Greeti } select { - case <- ctx.Done(): - return - case ch <- out: + case <-ctx.Done(): + return + case ch <- out: } } } - var logger_server_GreetingService = pd5.Logger("service/server/greetingservice") type GreetingService_Server interface { - Hello(ctx pd7.Context, req *HelloRequest) (<-chan *GreetingService_Hello_AsyncResult, error) } @@ -1370,9 +1343,9 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { } var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{ Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())} } + env = &AnonInductive5{Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())}} } else { - env = &AnonInductive5{ Hello: resp.Resp } + env = &AnonInductive5{Hello: resp.Resp} } var buf pd6.Buffer if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { @@ -1387,14 +1360,12 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { } } - case env.Identify != nil: var env *AnonInductive5 env = &AnonInductive5{ Identify: &GreetingService_IdentifyResult{ Methods: []pd1.String{ "Hello", - }, }, } @@ -1417,9 +1388,8 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { // -- protocol type HelloRequest -- type HelloRequest struct { - Name pd1.String - Address Address - + Name pd1.String + Address Address } func (x HelloRequest) Node() pd3.Node { @@ -1432,9 +1402,8 @@ func (x *HelloRequest) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Name": x.Name.Parse, + "Name": x.Name.Parse, "Address": x.Address.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1445,22 +1414,22 @@ func (x *HelloRequest) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Name": - if _, notParsed := fieldMap["Name"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Name") - } - if err := x.Name.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Name") - case "Address": - if _, notParsed := fieldMap["Address"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Address") - } - if err := x.Address.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Address") + case "Name": + if _, notParsed := fieldMap["Name"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Name") + } + if err := x.Name.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Name") + case "Address": + if _, notParsed := fieldMap["Address"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Address") + } + if err := x.Address.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Address") } } @@ -1482,17 +1451,17 @@ type HelloRequest_MapIterator struct { func (x *HelloRequest_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Name"), x.s.Name.Node(), nil - case 1: - return pd1.String("Address"), x.s.Address.Node(), nil + case 0: + return pd1.String("Name"), x.s.Name.Node(), nil + case 1: + return pd1.String("Address"), x.s.Address.Node(), nil } return nil, nil, pd1.ErrNA } func (x *HelloRequest_MapIterator) Done() bool { - return x.i + 1 >= 2 + return x.i+1 >= 2 } func (x HelloRequest) Kind() pd3.Kind { @@ -1501,9 +1470,9 @@ func (x HelloRequest) Kind() pd3.Kind { func (x HelloRequest) LookupByString(key string) (pd3.Node, error) { switch key { - case "Name": + case "Name": return x.Name.Node(), nil - case "Address": + case "Address": return x.Address.Node(), nil } @@ -1530,9 +1499,9 @@ func (x HelloRequest) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x HelloRequest) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Name.Node(), nil - case 1: + case 1: return x.Address.Node(), nil } @@ -1541,9 +1510,9 @@ func (x HelloRequest) LookupByIndex(idx int64) (pd3.Node, error) { func (x HelloRequest) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Name": + case "0", "Name": return x.Name.Node(), nil - case "1", "Address": + case "1", "Address": return x.Address.Node(), nil } @@ -1721,16 +1690,15 @@ func (iter *AddressLines_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AddressLines_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type Address -- type Address struct { - US *USAddress - SK *SKAddress - - - OtherCountry string - OtherAddress *AddressLines + US *USAddress + SK *SKAddress + OtherCountry string + OtherAddress *AddressLines } func (x *Address) Parse(n pd3.Node) error { @@ -1763,7 +1731,6 @@ func (x *Address) Parse(n pd3.Node) error { x.SK = &y return nil - default: var y AddressLines if err := y.Parse(vn); err != nil { @@ -1788,14 +1755,13 @@ func (x *Address_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { } else { x.done = true switch { - case x.s.US != nil: + case x.s.US != nil: return pd1.String("US"), x.s.US.Node(), nil - case x.s.SK != nil: + case x.s.SK != nil: return pd1.String("SouthKorea"), x.s.SK.Node(), nil - - case x.s.OtherAddress != nil: - return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil + case x.s.OtherAddress != nil: + return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil default: return nil, nil, pd2.Errorf("no inductive cases are set") @@ -1817,12 +1783,11 @@ func (x Address) Kind() pd3.Kind { func (x Address) LookupByString(key string) (pd3.Node, error) { switch { - case x.US != nil && key == "US": + case x.US != nil && key == "US": return x.US.Node(), nil - case x.SK != nil && key == "SouthKorea": + case x.SK != nil && key == "SouthKorea": return x.SK.Node(), nil - case x.OtherAddress != nil && key == x.OtherCountry: return x.OtherAddress.Node(), nil @@ -1847,12 +1812,11 @@ func (x Address) LookupByIndex(idx int64) (pd3.Node, error) { func (x Address) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "US": + case "US": return x.US.Node(), nil - case "SouthKorea": + case "SouthKorea": return x.SK.Node(), nil - case x.OtherCountry: return x.OtherAddress.Node(), nil @@ -1907,14 +1871,14 @@ func (x Address) AsLink() (pd3.Link, error) { func (x Address) Prototype() pd3.NodePrototype { return nil } + // -- protocol type USAddress -- type USAddress struct { - Street pd1.String - City pd1.String - State State - ZIP pd1.Int - + Street pd1.String + City pd1.String + State State + ZIP pd1.Int } func (x USAddress) Node() pd3.Node { @@ -1927,11 +1891,10 @@ func (x *USAddress) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "street": x.Street.Parse, - "city": x.City.Parse, - "state": x.State.Parse, - "zip": x.ZIP.Parse, - + "street": x.Street.Parse, + "city": x.City.Parse, + "state": x.State.Parse, + "zip": x.ZIP.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1942,38 +1905,38 @@ func (x *USAddress) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "street": - if _, notParsed := fieldMap["street"]; !notParsed { - return pd2.Errorf("field %s already parsed", "street") - } - if err := x.Street.Parse(vn); err != nil { - return err - } - delete(fieldMap, "street") - case "city": - if _, notParsed := fieldMap["city"]; !notParsed { - return pd2.Errorf("field %s already parsed", "city") - } - if err := x.City.Parse(vn); err != nil { - return err - } - delete(fieldMap, "city") - case "state": - if _, notParsed := fieldMap["state"]; !notParsed { - return pd2.Errorf("field %s already parsed", "state") - } - if err := x.State.Parse(vn); err != nil { - return err - } - delete(fieldMap, "state") - case "zip": - if _, notParsed := fieldMap["zip"]; !notParsed { - return pd2.Errorf("field %s already parsed", "zip") - } - if err := x.ZIP.Parse(vn); err != nil { - return err - } - delete(fieldMap, "zip") + case "street": + if _, notParsed := fieldMap["street"]; !notParsed { + return pd2.Errorf("field %s already parsed", "street") + } + if err := x.Street.Parse(vn); err != nil { + return err + } + delete(fieldMap, "street") + case "city": + if _, notParsed := fieldMap["city"]; !notParsed { + return pd2.Errorf("field %s already parsed", "city") + } + if err := x.City.Parse(vn); err != nil { + return err + } + delete(fieldMap, "city") + case "state": + if _, notParsed := fieldMap["state"]; !notParsed { + return pd2.Errorf("field %s already parsed", "state") + } + if err := x.State.Parse(vn); err != nil { + return err + } + delete(fieldMap, "state") + case "zip": + if _, notParsed := fieldMap["zip"]; !notParsed { + return pd2.Errorf("field %s already parsed", "zip") + } + if err := x.ZIP.Parse(vn); err != nil { + return err + } + delete(fieldMap, "zip") } } @@ -1995,21 +1958,21 @@ type USAddress_MapIterator struct { func (x *USAddress_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("street"), x.s.Street.Node(), nil - case 1: - return pd1.String("city"), x.s.City.Node(), nil - case 2: - return pd1.String("state"), x.s.State.Node(), nil - case 3: - return pd1.String("zip"), x.s.ZIP.Node(), nil + case 0: + return pd1.String("street"), x.s.Street.Node(), nil + case 1: + return pd1.String("city"), x.s.City.Node(), nil + case 2: + return pd1.String("state"), x.s.State.Node(), nil + case 3: + return pd1.String("zip"), x.s.ZIP.Node(), nil } return nil, nil, pd1.ErrNA } func (x *USAddress_MapIterator) Done() bool { - return x.i + 1 >= 4 + return x.i+1 >= 4 } func (x USAddress) Kind() pd3.Kind { @@ -2018,13 +1981,13 @@ func (x USAddress) Kind() pd3.Kind { func (x USAddress) LookupByString(key string) (pd3.Node, error) { switch key { - case "street": + case "street": return x.Street.Node(), nil - case "city": + case "city": return x.City.Node(), nil - case "state": + case "state": return x.State.Node(), nil - case "zip": + case "zip": return x.ZIP.Node(), nil } @@ -2051,13 +2014,13 @@ func (x USAddress) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x USAddress) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Street.Node(), nil - case 1: + case 1: return x.City.Node(), nil - case 2: + case 2: return x.State.Node(), nil - case 3: + case 3: return x.ZIP.Node(), nil } @@ -2066,13 +2029,13 @@ func (x USAddress) LookupByIndex(idx int64) (pd3.Node, error) { func (x USAddress) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "street": + case "0", "street": return x.Street.Node(), nil - case "1", "city": + case "1", "city": return x.City.Node(), nil - case "2", "state": + case "2", "state": return x.State.Node(), nil - case "3", "zip": + case "3", "zip": return x.ZIP.Node(), nil } @@ -2310,32 +2273,31 @@ func (StateNY) Prototype() pd3.NodePrototype { // -- protocol type State -- type State struct { - CA *StateCA - NY *StateNY - Other *pd1.String - + CA *StateCA + NY *StateNY + Other *pd1.String } func (x *State) Parse(n pd3.Node) error { *x = State{} - - var CA StateCA - if err := CA.Parse(n); err == nil { - x.CA = &CA - return nil - } - - var NY StateNY - if err := NY.Parse(n); err == nil { - x.NY = &NY - return nil - } - - var Other pd1.String - if err := Other.Parse(n); err == nil { - x.Other = &Other - return nil - } + + var CA StateCA + if err := CA.Parse(n); err == nil { + x.CA = &CA + return nil + } + + var NY StateNY + if err := NY.Parse(n); err == nil { + x.NY = &NY + return nil + } + + var Other pd1.String + if err := Other.Parse(n); err == nil { + x.Other = &Other + return nil + } return pd2.Errorf("no union cases parses") } @@ -2357,129 +2319,225 @@ func (x State) Node() pd3.Node { // proxy Node methods to active case func (x State) Kind() pd3.Kind { - if x.CA != nil { return x.CA.Kind() } - if x.NY != nil { return x.NY.Kind() } - if x.Other != nil { return x.Other.Kind() } + if x.CA != nil { + return x.CA.Kind() + } + if x.NY != nil { + return x.NY.Kind() + } + if x.Other != nil { + return x.Other.Kind() + } return pd3.Kind_Invalid } func (x State) LookupByString(key string) (pd3.Node, error) { - if x.CA != nil { return x.CA.LookupByString(key) } - if x.NY != nil { return x.NY.LookupByString(key) } - if x.Other != nil { return x.Other.LookupByString(key) } + if x.CA != nil { + return x.CA.LookupByString(key) + } + if x.NY != nil { + return x.NY.LookupByString(key) + } + if x.Other != nil { + return x.Other.LookupByString(key) + } return nil, pd2.Errorf("no active union case found") } func (x State) LookupByNode(key pd3.Node) (pd3.Node, error) { - if x.CA != nil { return x.CA.LookupByNode(key) } - if x.NY != nil { return x.NY.LookupByNode(key) } - if x.Other != nil { return x.Other.LookupByNode(key) } + if x.CA != nil { + return x.CA.LookupByNode(key) + } + if x.NY != nil { + return x.NY.LookupByNode(key) + } + if x.Other != nil { + return x.Other.LookupByNode(key) + } return nil, pd2.Errorf("no active union case found") } func (x State) LookupByIndex(idx int64) (pd3.Node, error) { - if x.CA != nil { return x.CA.LookupByIndex(idx) } - if x.NY != nil { return x.NY.LookupByIndex(idx) } - if x.Other != nil { return x.Other.LookupByIndex(idx) } + if x.CA != nil { + return x.CA.LookupByIndex(idx) + } + if x.NY != nil { + return x.NY.LookupByIndex(idx) + } + if x.Other != nil { + return x.Other.LookupByIndex(idx) + } return nil, pd2.Errorf("no active union case found") } func (x State) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { - if x.CA != nil { return x.CA.LookupBySegment(seg) } - if x.NY != nil { return x.NY.LookupBySegment(seg) } - if x.Other != nil { return x.Other.LookupBySegment(seg) } + if x.CA != nil { + return x.CA.LookupBySegment(seg) + } + if x.NY != nil { + return x.NY.LookupBySegment(seg) + } + if x.Other != nil { + return x.Other.LookupBySegment(seg) + } return nil, pd2.Errorf("no active union case found") } func (x State) MapIterator() pd3.MapIterator { - if x.CA != nil { return x.CA.MapIterator() } - if x.NY != nil { return x.NY.MapIterator() } - if x.Other != nil { return x.Other.MapIterator() } + if x.CA != nil { + return x.CA.MapIterator() + } + if x.NY != nil { + return x.NY.MapIterator() + } + if x.Other != nil { + return x.Other.MapIterator() + } return nil } func (x State) ListIterator() pd3.ListIterator { - if x.CA != nil { return x.CA.ListIterator() } - if x.NY != nil { return x.NY.ListIterator() } - if x.Other != nil { return x.Other.ListIterator() } + if x.CA != nil { + return x.CA.ListIterator() + } + if x.NY != nil { + return x.NY.ListIterator() + } + if x.Other != nil { + return x.Other.ListIterator() + } return nil } func (x State) Length() int64 { - if x.CA != nil { return x.CA.Length() } - if x.NY != nil { return x.NY.Length() } - if x.Other != nil { return x.Other.Length() } + if x.CA != nil { + return x.CA.Length() + } + if x.NY != nil { + return x.NY.Length() + } + if x.Other != nil { + return x.Other.Length() + } return -1 } func (x State) IsAbsent() bool { - if x.CA != nil { return x.CA.IsAbsent() } - if x.NY != nil { return x.NY.IsAbsent() } - if x.Other != nil { return x.Other.IsAbsent() } + if x.CA != nil { + return x.CA.IsAbsent() + } + if x.NY != nil { + return x.NY.IsAbsent() + } + if x.Other != nil { + return x.Other.IsAbsent() + } return false } func (x State) IsNull() bool { - if x.CA != nil { return x.CA.IsNull() } - if x.NY != nil { return x.NY.IsNull() } - if x.Other != nil { return x.Other.IsNull() } + if x.CA != nil { + return x.CA.IsNull() + } + if x.NY != nil { + return x.NY.IsNull() + } + if x.Other != nil { + return x.Other.IsNull() + } return false } func (x State) AsBool() (bool, error) { - if x.CA != nil { return x.CA.AsBool() } - if x.NY != nil { return x.NY.AsBool() } - if x.Other != nil { return x.Other.AsBool() } + if x.CA != nil { + return x.CA.AsBool() + } + if x.NY != nil { + return x.NY.AsBool() + } + if x.Other != nil { + return x.Other.AsBool() + } return false, pd2.Errorf("no active union case found") } func (x State) AsInt() (int64, error) { - if x.CA != nil { return x.CA.AsInt() } - if x.NY != nil { return x.NY.AsInt() } - if x.Other != nil { return x.Other.AsInt() } + if x.CA != nil { + return x.CA.AsInt() + } + if x.NY != nil { + return x.NY.AsInt() + } + if x.Other != nil { + return x.Other.AsInt() + } return 0, pd2.Errorf("no active union case found") } func (x State) AsFloat() (float64, error) { - if x.CA != nil { return x.CA.AsFloat() } - if x.NY != nil { return x.NY.AsFloat() } - if x.Other != nil { return x.Other.AsFloat() } + if x.CA != nil { + return x.CA.AsFloat() + } + if x.NY != nil { + return x.NY.AsFloat() + } + if x.Other != nil { + return x.Other.AsFloat() + } return 0.0, pd2.Errorf("no active union case found") } func (x State) AsString() (string, error) { - if x.CA != nil { return x.CA.AsString() } - if x.NY != nil { return x.NY.AsString() } - if x.Other != nil { return x.Other.AsString() } + if x.CA != nil { + return x.CA.AsString() + } + if x.NY != nil { + return x.NY.AsString() + } + if x.Other != nil { + return x.Other.AsString() + } return "", pd2.Errorf("no active union case found") } func (x State) AsBytes() ([]byte, error) { - if x.CA != nil { return x.CA.AsBytes() } - if x.NY != nil { return x.NY.AsBytes() } - if x.Other != nil { return x.Other.AsBytes() } + if x.CA != nil { + return x.CA.AsBytes() + } + if x.NY != nil { + return x.NY.AsBytes() + } + if x.Other != nil { + return x.Other.AsBytes() + } return nil, pd2.Errorf("no active union case found") } func (x State) AsLink() (pd3.Link, error) { - if x.CA != nil { return x.CA.AsLink() } - if x.NY != nil { return x.NY.AsLink() } - if x.Other != nil { return x.Other.AsLink() } + if x.CA != nil { + return x.CA.AsLink() + } + if x.NY != nil { + return x.NY.AsLink() + } + if x.Other != nil { + return x.Other.AsLink() + } return nil, pd2.Errorf("no active union case found") } @@ -2487,14 +2545,14 @@ func (x State) AsLink() (pd3.Link, error) { func (x State) Prototype() pd3.NodePrototype { return nil } + // -- protocol type SKAddress -- type SKAddress struct { - Street pd1.String - City pd1.String - Province pd1.String - PostalCode pd1.Int - + Street pd1.String + City pd1.String + Province pd1.String + PostalCode pd1.Int } func (x SKAddress) Node() pd3.Node { @@ -2507,11 +2565,10 @@ func (x *SKAddress) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "street": x.Street.Parse, - "city": x.City.Parse, - "province": x.Province.Parse, + "street": x.Street.Parse, + "city": x.City.Parse, + "province": x.Province.Parse, "postal_code": x.PostalCode.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2522,38 +2579,38 @@ func (x *SKAddress) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "street": - if _, notParsed := fieldMap["street"]; !notParsed { - return pd2.Errorf("field %s already parsed", "street") - } - if err := x.Street.Parse(vn); err != nil { - return err - } - delete(fieldMap, "street") - case "city": - if _, notParsed := fieldMap["city"]; !notParsed { - return pd2.Errorf("field %s already parsed", "city") - } - if err := x.City.Parse(vn); err != nil { - return err - } - delete(fieldMap, "city") - case "province": - if _, notParsed := fieldMap["province"]; !notParsed { - return pd2.Errorf("field %s already parsed", "province") - } - if err := x.Province.Parse(vn); err != nil { - return err - } - delete(fieldMap, "province") - case "postal_code": - if _, notParsed := fieldMap["postal_code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "postal_code") - } - if err := x.PostalCode.Parse(vn); err != nil { - return err - } - delete(fieldMap, "postal_code") + case "street": + if _, notParsed := fieldMap["street"]; !notParsed { + return pd2.Errorf("field %s already parsed", "street") + } + if err := x.Street.Parse(vn); err != nil { + return err + } + delete(fieldMap, "street") + case "city": + if _, notParsed := fieldMap["city"]; !notParsed { + return pd2.Errorf("field %s already parsed", "city") + } + if err := x.City.Parse(vn); err != nil { + return err + } + delete(fieldMap, "city") + case "province": + if _, notParsed := fieldMap["province"]; !notParsed { + return pd2.Errorf("field %s already parsed", "province") + } + if err := x.Province.Parse(vn); err != nil { + return err + } + delete(fieldMap, "province") + case "postal_code": + if _, notParsed := fieldMap["postal_code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "postal_code") + } + if err := x.PostalCode.Parse(vn); err != nil { + return err + } + delete(fieldMap, "postal_code") } } @@ -2575,21 +2632,21 @@ type SKAddress_MapIterator struct { func (x *SKAddress_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("street"), x.s.Street.Node(), nil - case 1: - return pd1.String("city"), x.s.City.Node(), nil - case 2: - return pd1.String("province"), x.s.Province.Node(), nil - case 3: - return pd1.String("postal_code"), x.s.PostalCode.Node(), nil + case 0: + return pd1.String("street"), x.s.Street.Node(), nil + case 1: + return pd1.String("city"), x.s.City.Node(), nil + case 2: + return pd1.String("province"), x.s.Province.Node(), nil + case 3: + return pd1.String("postal_code"), x.s.PostalCode.Node(), nil } return nil, nil, pd1.ErrNA } func (x *SKAddress_MapIterator) Done() bool { - return x.i + 1 >= 4 + return x.i+1 >= 4 } func (x SKAddress) Kind() pd3.Kind { @@ -2598,13 +2655,13 @@ func (x SKAddress) Kind() pd3.Kind { func (x SKAddress) LookupByString(key string) (pd3.Node, error) { switch key { - case "street": + case "street": return x.Street.Node(), nil - case "city": + case "city": return x.City.Node(), nil - case "province": + case "province": return x.Province.Node(), nil - case "postal_code": + case "postal_code": return x.PostalCode.Node(), nil } @@ -2631,13 +2688,13 @@ func (x SKAddress) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x SKAddress) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Street.Node(), nil - case 1: + case 1: return x.City.Node(), nil - case 2: + case 2: return x.Province.Node(), nil - case 3: + case 3: return x.PostalCode.Node(), nil } @@ -2646,13 +2703,13 @@ func (x SKAddress) LookupByIndex(idx int64) (pd3.Node, error) { func (x SKAddress) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "street": + case "0", "street": return x.Street.Node(), nil - case "1", "city": + case "1", "city": return x.City.Node(), nil - case "2", "province": + case "2", "province": return x.Province.Node(), nil - case "3", "postal_code": + case "3", "postal_code": return x.PostalCode.Node(), nil } @@ -2710,25 +2767,24 @@ func (x SKAddress) Prototype() pd3.NodePrototype { // -- protocol type HelloResponse -- type HelloResponse struct { - English *pd1.String - Korean *pd1.String - + English *pd1.String + Korean *pd1.String } func (x *HelloResponse) Parse(n pd3.Node) error { *x = HelloResponse{} - - var English pd1.String - if err := English.Parse(n); err == nil { - x.English = &English - return nil - } - - var Korean pd1.String - if err := Korean.Parse(n); err == nil { - x.Korean = &Korean - return nil - } + + var English pd1.String + if err := English.Parse(n); err == nil { + x.English = &English + return nil + } + + var Korean pd1.String + if err := Korean.Parse(n); err == nil { + x.Korean = &Korean + return nil + } return pd2.Errorf("no union cases parses") } @@ -2747,117 +2803,181 @@ func (x HelloResponse) Node() pd3.Node { // proxy Node methods to active case func (x HelloResponse) Kind() pd3.Kind { - if x.English != nil { return x.English.Kind() } - if x.Korean != nil { return x.Korean.Kind() } + if x.English != nil { + return x.English.Kind() + } + if x.Korean != nil { + return x.Korean.Kind() + } return pd3.Kind_Invalid } func (x HelloResponse) LookupByString(key string) (pd3.Node, error) { - if x.English != nil { return x.English.LookupByString(key) } - if x.Korean != nil { return x.Korean.LookupByString(key) } + if x.English != nil { + return x.English.LookupByString(key) + } + if x.Korean != nil { + return x.Korean.LookupByString(key) + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupByNode(key pd3.Node) (pd3.Node, error) { - if x.English != nil { return x.English.LookupByNode(key) } - if x.Korean != nil { return x.Korean.LookupByNode(key) } + if x.English != nil { + return x.English.LookupByNode(key) + } + if x.Korean != nil { + return x.Korean.LookupByNode(key) + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupByIndex(idx int64) (pd3.Node, error) { - if x.English != nil { return x.English.LookupByIndex(idx) } - if x.Korean != nil { return x.Korean.LookupByIndex(idx) } + if x.English != nil { + return x.English.LookupByIndex(idx) + } + if x.Korean != nil { + return x.Korean.LookupByIndex(idx) + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { - if x.English != nil { return x.English.LookupBySegment(seg) } - if x.Korean != nil { return x.Korean.LookupBySegment(seg) } + if x.English != nil { + return x.English.LookupBySegment(seg) + } + if x.Korean != nil { + return x.Korean.LookupBySegment(seg) + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) MapIterator() pd3.MapIterator { - if x.English != nil { return x.English.MapIterator() } - if x.Korean != nil { return x.Korean.MapIterator() } + if x.English != nil { + return x.English.MapIterator() + } + if x.Korean != nil { + return x.Korean.MapIterator() + } return nil } func (x HelloResponse) ListIterator() pd3.ListIterator { - if x.English != nil { return x.English.ListIterator() } - if x.Korean != nil { return x.Korean.ListIterator() } + if x.English != nil { + return x.English.ListIterator() + } + if x.Korean != nil { + return x.Korean.ListIterator() + } return nil } func (x HelloResponse) Length() int64 { - if x.English != nil { return x.English.Length() } - if x.Korean != nil { return x.Korean.Length() } + if x.English != nil { + return x.English.Length() + } + if x.Korean != nil { + return x.Korean.Length() + } return -1 } func (x HelloResponse) IsAbsent() bool { - if x.English != nil { return x.English.IsAbsent() } - if x.Korean != nil { return x.Korean.IsAbsent() } + if x.English != nil { + return x.English.IsAbsent() + } + if x.Korean != nil { + return x.Korean.IsAbsent() + } return false } func (x HelloResponse) IsNull() bool { - if x.English != nil { return x.English.IsNull() } - if x.Korean != nil { return x.Korean.IsNull() } + if x.English != nil { + return x.English.IsNull() + } + if x.Korean != nil { + return x.Korean.IsNull() + } return false } func (x HelloResponse) AsBool() (bool, error) { - if x.English != nil { return x.English.AsBool() } - if x.Korean != nil { return x.Korean.AsBool() } + if x.English != nil { + return x.English.AsBool() + } + if x.Korean != nil { + return x.Korean.AsBool() + } return false, pd2.Errorf("no active union case found") } func (x HelloResponse) AsInt() (int64, error) { - if x.English != nil { return x.English.AsInt() } - if x.Korean != nil { return x.Korean.AsInt() } + if x.English != nil { + return x.English.AsInt() + } + if x.Korean != nil { + return x.Korean.AsInt() + } return 0, pd2.Errorf("no active union case found") } func (x HelloResponse) AsFloat() (float64, error) { - if x.English != nil { return x.English.AsFloat() } - if x.Korean != nil { return x.Korean.AsFloat() } + if x.English != nil { + return x.English.AsFloat() + } + if x.Korean != nil { + return x.Korean.AsFloat() + } return 0.0, pd2.Errorf("no active union case found") } func (x HelloResponse) AsString() (string, error) { - if x.English != nil { return x.English.AsString() } - if x.Korean != nil { return x.Korean.AsString() } + if x.English != nil { + return x.English.AsString() + } + if x.Korean != nil { + return x.Korean.AsString() + } return "", pd2.Errorf("no active union case found") } func (x HelloResponse) AsBytes() ([]byte, error) { - if x.English != nil { return x.English.AsBytes() } - if x.Korean != nil { return x.Korean.AsBytes() } + if x.English != nil { + return x.English.AsBytes() + } + if x.Korean != nil { + return x.Korean.AsBytes() + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) AsLink() (pd3.Link, error) { - if x.English != nil { return x.English.AsLink() } - if x.Korean != nil { return x.Korean.AsLink() } + if x.English != nil { + return x.English.AsLink() + } + if x.Korean != nil { + return x.Korean.AsLink() + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) Prototype() pd3.NodePrototype { return nil -} \ No newline at end of file +} From 7d99a398191387ee29b5a74b2b323244ee83f49a Mon Sep 17 00:00:00 2001 From: galargh Date: Thu, 1 Sep 2022 17:45:57 +0200 Subject: [PATCH 3/4] fix: use go1.18 for gofmt and gen --- blueprints/values/inductive.go | 2 +- blueprints/values/structure.go | 4 +- blueprints/values/union.go | 2 +- .../gen-routing-api/proto/proto_edelweiss.go | 529 +++++----- .../api/proto/proto_edelweiss.go | 934 ++++++++---------- 5 files changed, 700 insertions(+), 771 deletions(-) diff --git a/blueprints/values/inductive.go b/blueprints/values/inductive.go index 12d6c3b..cd99174 100644 --- a/blueprints/values/inductive.go +++ b/blueprints/values/inductive.go @@ -48,7 +48,7 @@ func (x *GoInductiveImpl) GoDef() cg.Blueprint { for i := range cases { caseDecls[i] = cg.T{ Data: caseData[i], - Src: " {{.CaseName}} *{{.CaseType}}\n", + Src: " {{.CaseName}} *{{.CaseType}}\n", } } // build case parse cases diff --git a/blueprints/values/structure.go b/blueprints/values/structure.go index 47e865c..e74ff40 100644 --- a/blueprints/values/structure.go +++ b/blueprints/values/structure.go @@ -53,7 +53,7 @@ func (x *GoStructureImpl) GoDef() cg.Blueprint { for i := range fields { fieldDecls[i] = cg.T{ Data: fieldData[i], - Src: " {{.FieldName}} {{.FieldType}}\n", + Src: " {{.FieldName}} {{.FieldType}}\n", } } // build field parse cases @@ -62,7 +62,7 @@ func (x *GoStructureImpl) GoDef() cg.Blueprint { for i := range fields { fieldParseMapCases[i] = cg.T{ Data: fieldData[i], - Src: " {{.FieldNameString}}: x.{{.FieldName}}.Parse,\n", + Src: " {{.FieldNameString}}: x.{{.FieldName}}.Parse,\n", } fieldParseCases[i] = cg.T{ Data: fieldData[i], diff --git a/blueprints/values/union.go b/blueprints/values/union.go index 7d7408d..f19c46a 100644 --- a/blueprints/values/union.go +++ b/blueprints/values/union.go @@ -47,7 +47,7 @@ func (x *GoUnionImpl) GoDef() cg.Blueprint { for i := range cases { caseDecls[i] = cg.T{ Data: caseData[i], - Src: " {{.CaseName}} *{{.CaseType}}\n", + Src: " {{.CaseName}} *{{.CaseType}}\n", } } // build cases for Node() method diff --git a/examples/gen-routing-api/proto/proto_edelweiss.go b/examples/gen-routing-api/proto/proto_edelweiss.go index 69085f9..3bc6f48 100644 --- a/examples/gen-routing-api/proto/proto_edelweiss.go +++ b/examples/gen-routing-api/proto/proto_edelweiss.go @@ -2,26 +2,28 @@ package proto -import ( - pd6 "bytes" - pd7 "context" - pd9 "errors" +import( + pd1 "github.com/ipld/edelweiss/values" pd2 "fmt" + pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd4 "net/http" pd5 "github.com/ipfs/go-log/v2" - pd13 "github.com/ipld/edelweiss/services" - pd1 "github.com/ipld/edelweiss/values" - pd11 "github.com/ipld/go-ipld-prime" + pd6 "bytes" + pd7 "context" pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" - pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd9 "errors" pd10 "io" - pd4 "net/http" + pd11 "github.com/ipld/go-ipld-prime" pd12 "net/url" + pd13 "github.com/ipld/edelweiss/services" pd14 "sync" ) + // -- protocol type DelegatedRouting_IdentifyArg -- type DelegatedRouting_IdentifyArg struct { + } func (x DelegatedRouting_IdentifyArg) Node() pd3.Node { @@ -33,7 +35,9 @@ func (x *DelegatedRouting_IdentifyArg) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{ + + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -70,7 +74,7 @@ func (x *DelegatedRouting_IdentifyArg_MapIterator) Next() (key pd3.Node, value p } func (x *DelegatedRouting_IdentifyArg_MapIterator) Done() bool { - return x.i+1 >= 0 + return x.i + 1 >= 0 } func (x DelegatedRouting_IdentifyArg) Kind() pd3.Kind { @@ -287,11 +291,11 @@ func (iter *AnonList1_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList1_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type DelegatedRouting_IdentifyResult -- type DelegatedRouting_IdentifyResult struct { - Methods AnonList1 + Methods AnonList1 + } func (x DelegatedRouting_IdentifyResult) Node() pd3.Node { @@ -304,7 +308,8 @@ func (x *DelegatedRouting_IdentifyResult) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Methods": x.Methods.Parse, + "Methods": x.Methods.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -315,14 +320,14 @@ func (x *DelegatedRouting_IdentifyResult) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Methods": - if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Methods") - } - if err := x.Methods.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Methods") + case "Methods": + if _, notParsed := fieldMap["Methods"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Methods") + } + if err := x.Methods.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Methods") } } @@ -344,15 +349,15 @@ type DelegatedRouting_IdentifyResult_MapIterator struct { func (x *DelegatedRouting_IdentifyResult_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Methods"), x.s.Methods.Node(), nil + case 0: + return pd1.String("Methods"), x.s.Methods.Node(), nil } return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_IdentifyResult_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } func (x DelegatedRouting_IdentifyResult) Kind() pd3.Kind { @@ -361,7 +366,7 @@ func (x DelegatedRouting_IdentifyResult) Kind() pd3.Kind { func (x DelegatedRouting_IdentifyResult) LookupByString(key string) (pd3.Node, error) { switch key { - case "Methods": + case "Methods": return x.Methods.Node(), nil } @@ -388,7 +393,7 @@ func (x DelegatedRouting_IdentifyResult) LookupByNode(key pd3.Node) (pd3.Node, e func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Methods.Node(), nil } @@ -397,7 +402,7 @@ func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, err func (x DelegatedRouting_IdentifyResult) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Methods": + case "0", "Methods": return x.Methods.Node(), nil } @@ -455,7 +460,8 @@ func (x DelegatedRouting_IdentifyResult) Prototype() pd3.NodePrototype { // -- protocol type DelegatedRouting_Error -- type DelegatedRouting_Error struct { - Code pd1.String + Code pd1.String + } func (x DelegatedRouting_Error) Node() pd3.Node { @@ -468,7 +474,8 @@ func (x *DelegatedRouting_Error) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Code": x.Code.Parse, + "Code": x.Code.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -479,14 +486,14 @@ func (x *DelegatedRouting_Error) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Code": - if _, notParsed := fieldMap["Code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Code") - } - if err := x.Code.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Code") + case "Code": + if _, notParsed := fieldMap["Code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Code") + } + if err := x.Code.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Code") } } @@ -508,15 +515,15 @@ type DelegatedRouting_Error_MapIterator struct { func (x *DelegatedRouting_Error_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Code"), x.s.Code.Node(), nil + case 0: + return pd1.String("Code"), x.s.Code.Node(), nil } return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_Error_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } func (x DelegatedRouting_Error) Kind() pd3.Kind { @@ -525,7 +532,7 @@ func (x DelegatedRouting_Error) Kind() pd3.Kind { func (x DelegatedRouting_Error) LookupByString(key string) (pd3.Node, error) { switch key { - case "Code": + case "Code": return x.Code.Node(), nil } @@ -552,7 +559,7 @@ func (x DelegatedRouting_Error) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Code.Node(), nil } @@ -561,7 +568,7 @@ func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd3.Node, error) { func (x DelegatedRouting_Error) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Code": + case "0", "Code": return x.Code.Node(), nil } @@ -619,8 +626,10 @@ func (x DelegatedRouting_Error) Prototype() pd3.NodePrototype { // -- protocol type AnonInductive4 -- type AnonInductive4 struct { - Identify *DelegatedRouting_IdentifyArg - GetP2PProvide *GetP2PProvideRequest + Identify *DelegatedRouting_IdentifyArg + GetP2PProvide *GetP2PProvideRequest + + } func (x *AnonInductive4) Parse(n pd3.Node) error { @@ -653,6 +662,7 @@ func (x *AnonInductive4) Parse(n pd3.Node) error { x.GetP2PProvide = &y return nil + } return pd2.Errorf("inductive map has no applicable keys") @@ -670,11 +680,12 @@ func (x *AnonInductive4_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil - case x.s.GetP2PProvide != nil: + case x.s.GetP2PProvide != nil: return pd1.String("GetP2PProvideRequest"), x.s.GetP2PProvide.Node(), nil + default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -695,11 +706,12 @@ func (x AnonInductive4) Kind() pd3.Kind { func (x AnonInductive4) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyRequest": + case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil - case x.GetP2PProvide != nil && key == "GetP2PProvideRequest": + case x.GetP2PProvide != nil && key == "GetP2PProvideRequest": return x.GetP2PProvide.Node(), nil + } return nil, pd1.ErrNA } @@ -721,11 +733,12 @@ func (x AnonInductive4) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive4) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyRequest": + case "IdentifyRequest": return x.Identify.Node(), nil - case "GetP2PProvideRequest": + case "GetP2PProvideRequest": return x.GetP2PProvide.Node(), nil + } return nil, pd1.ErrNA } @@ -777,13 +790,14 @@ func (x AnonInductive4) AsLink() (pd3.Link, error) { func (x AnonInductive4) Prototype() pd3.NodePrototype { return nil } - // -- protocol type AnonInductive5 -- type AnonInductive5 struct { - Identify *DelegatedRouting_IdentifyResult - GetP2PProvide *GetP2PProvideResponse - Error *DelegatedRouting_Error + Identify *DelegatedRouting_IdentifyResult + GetP2PProvide *GetP2PProvideResponse + Error *DelegatedRouting_Error + + } func (x *AnonInductive5) Parse(n pd3.Node) error { @@ -823,6 +837,7 @@ func (x *AnonInductive5) Parse(n pd3.Node) error { x.Error = &y return nil + } return pd2.Errorf("inductive map has no applicable keys") @@ -840,13 +855,14 @@ func (x *AnonInductive5_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil - case x.s.GetP2PProvide != nil: + case x.s.GetP2PProvide != nil: return pd1.String("GetP2PProvideResponse"), x.s.GetP2PProvide.Node(), nil - case x.s.Error != nil: + case x.s.Error != nil: return pd1.String("Error"), x.s.Error.Node(), nil + default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -867,13 +883,14 @@ func (x AnonInductive5) Kind() pd3.Kind { func (x AnonInductive5) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyResponse": + case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil - case x.GetP2PProvide != nil && key == "GetP2PProvideResponse": + case x.GetP2PProvide != nil && key == "GetP2PProvideResponse": return x.GetP2PProvide.Node(), nil - case x.Error != nil && key == "Error": + case x.Error != nil && key == "Error": return x.Error.Node(), nil + } return nil, pd1.ErrNA } @@ -895,13 +912,14 @@ func (x AnonInductive5) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive5) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyResponse": + case "IdentifyResponse": return x.Identify.Node(), nil - case "GetP2PProvideResponse": + case "GetP2PProvideResponse": return x.GetP2PProvide.Node(), nil - case "Error": + case "Error": return x.Error.Node(), nil + } return nil, pd1.ErrNA } @@ -953,19 +971,22 @@ func (x AnonInductive5) AsLink() (pd3.Link, error) { func (x AnonInductive5) Prototype() pd3.NodePrototype { return nil } - var logger_client_DelegatedRouting = pd5.Logger("service/client/delegatedrouting") type DelegatedRouting_Client interface { - Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) - GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) +Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) - Identify_Async(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) +GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) + + +Identify_Async(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) + +GetP2PProvide_Async(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) - GetP2PProvide_Async(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) } + type DelegatedRouting_Identify_AsyncResult struct { Resp *DelegatedRouting_IdentifyResult Err error @@ -976,12 +997,13 @@ type DelegatedRouting_GetP2PProvide_AsyncResult struct { Err error } + type DelegatedRouting_ClientOption func(*client_DelegatedRouting) error type client_DelegatedRouting struct { - httpClient *pd4.Client - endpoint *pd12.URL - ulk pd14.Mutex + httpClient *pd4.Client + endpoint *pd12.URL + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } @@ -1006,6 +1028,8 @@ func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_Clien return c, nil } + + func (c *client_DelegatedRouting) Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1104,8 +1128,8 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd7.Context, ch chan<- De defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1138,13 +1162,14 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd7.Context, ch chan<- De } select { - case <-ctx.Done(): - return - case ch <- out: + case <- ctx.Done(): + return + case ch <- out: } } } + func (c *client_DelegatedRouting) GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1243,8 +1268,8 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd7.Context, ch chan defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1277,16 +1302,18 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd7.Context, ch chan } select { - case <-ctx.Done(): - return - case ch <- out: + case <- ctx.Done(): + return + case ch <- out: } } } + var logger_server_DelegatedRouting = pd5.Logger("service/server/delegatedrouting") type DelegatedRouting_Server interface { + GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) } @@ -1343,9 +1370,9 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())}} + env = &AnonInductive5{ Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())} } } else { - env = &AnonInductive5{GetP2PProvide: resp.Resp} + env = &AnonInductive5{ GetP2PProvide: resp.Resp } } var buf pd6.Buffer if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { @@ -1360,12 +1387,14 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } } + case env.Identify != nil: var env *AnonInductive5 env = &AnonInductive5{ Identify: &DelegatedRouting_IdentifyResult{ Methods: []pd1.String{ "GetP2PProvide", + }, }, } @@ -1508,11 +1537,11 @@ func (iter *AnonList7_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList7_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type GetP2PProvideRequest -- type GetP2PProvideRequest struct { - Keys AnonList7 + Keys AnonList7 + } func (x GetP2PProvideRequest) Node() pd3.Node { @@ -1525,7 +1554,8 @@ func (x *GetP2PProvideRequest) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Keys": x.Keys.Parse, + "Keys": x.Keys.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1536,14 +1566,14 @@ func (x *GetP2PProvideRequest) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Keys": - if _, notParsed := fieldMap["Keys"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Keys") - } - if err := x.Keys.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Keys") + case "Keys": + if _, notParsed := fieldMap["Keys"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Keys") + } + if err := x.Keys.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Keys") } } @@ -1565,15 +1595,15 @@ type GetP2PProvideRequest_MapIterator struct { func (x *GetP2PProvideRequest_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Keys"), x.s.Keys.Node(), nil + case 0: + return pd1.String("Keys"), x.s.Keys.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GetP2PProvideRequest_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } func (x GetP2PProvideRequest) Kind() pd3.Kind { @@ -1582,7 +1612,7 @@ func (x GetP2PProvideRequest) Kind() pd3.Kind { func (x GetP2PProvideRequest) LookupByString(key string) (pd3.Node, error) { switch key { - case "Keys": + case "Keys": return x.Keys.Node(), nil } @@ -1609,7 +1639,7 @@ func (x GetP2PProvideRequest) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Keys.Node(), nil } @@ -1618,7 +1648,7 @@ func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd3.Node, error) { func (x GetP2PProvideRequest) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Keys": + case "0", "Keys": return x.Keys.Node(), nil } @@ -1796,11 +1826,11 @@ func (iter *AnonList9_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList9_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type GetP2PProvideResponse -- type GetP2PProvideResponse struct { - ProvidersByKey AnonList9 + ProvidersByKey AnonList9 + } func (x GetP2PProvideResponse) Node() pd3.Node { @@ -1813,7 +1843,8 @@ func (x *GetP2PProvideResponse) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "ProvidersByKey": x.ProvidersByKey.Parse, + "ProvidersByKey": x.ProvidersByKey.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1824,14 +1855,14 @@ func (x *GetP2PProvideResponse) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "ProvidersByKey": - if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { - return pd2.Errorf("field %s already parsed", "ProvidersByKey") - } - if err := x.ProvidersByKey.Parse(vn); err != nil { - return err - } - delete(fieldMap, "ProvidersByKey") + case "ProvidersByKey": + if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { + return pd2.Errorf("field %s already parsed", "ProvidersByKey") + } + if err := x.ProvidersByKey.Parse(vn); err != nil { + return err + } + delete(fieldMap, "ProvidersByKey") } } @@ -1853,15 +1884,15 @@ type GetP2PProvideResponse_MapIterator struct { func (x *GetP2PProvideResponse_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil + case 0: + return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GetP2PProvideResponse_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } func (x GetP2PProvideResponse) Kind() pd3.Kind { @@ -1870,7 +1901,7 @@ func (x GetP2PProvideResponse) Kind() pd3.Kind { func (x GetP2PProvideResponse) LookupByString(key string) (pd3.Node, error) { switch key { - case "ProvidersByKey": + case "ProvidersByKey": return x.ProvidersByKey.Node(), nil } @@ -1897,7 +1928,7 @@ func (x GetP2PProvideResponse) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.ProvidersByKey.Node(), nil } @@ -1906,7 +1937,7 @@ func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd3.Node, error) { func (x GetP2PProvideResponse) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "ProvidersByKey": + case "0", "ProvidersByKey": return x.ProvidersByKey.Node(), nil } @@ -1964,8 +1995,9 @@ func (x GetP2PProvideResponse) Prototype() pd3.NodePrototype { // -- protocol type ProvidersByKey -- type ProvidersByKey struct { - Key Multihash - Provider Provider + Key Multihash + Provider Provider + } func (x ProvidersByKey) Node() pd3.Node { @@ -1978,8 +2010,9 @@ func (x *ProvidersByKey) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Key": x.Key.Parse, + "Key": x.Key.Parse, "Provider": x.Provider.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1990,22 +2023,22 @@ func (x *ProvidersByKey) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Key": - if _, notParsed := fieldMap["Key"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Key") - } - if err := x.Key.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Key") - case "Provider": - if _, notParsed := fieldMap["Provider"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Provider") - } - if err := x.Provider.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Provider") + case "Key": + if _, notParsed := fieldMap["Key"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Key") + } + if err := x.Key.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Key") + case "Provider": + if _, notParsed := fieldMap["Provider"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Provider") + } + if err := x.Provider.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Provider") } } @@ -2027,17 +2060,17 @@ type ProvidersByKey_MapIterator struct { func (x *ProvidersByKey_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Key"), x.s.Key.Node(), nil - case 1: - return pd1.String("Provider"), x.s.Provider.Node(), nil + case 0: + return pd1.String("Key"), x.s.Key.Node(), nil + case 1: + return pd1.String("Provider"), x.s.Provider.Node(), nil } return nil, nil, pd1.ErrNA } func (x *ProvidersByKey_MapIterator) Done() bool { - return x.i+1 >= 2 + return x.i + 1 >= 2 } func (x ProvidersByKey) Kind() pd3.Kind { @@ -2046,9 +2079,9 @@ func (x ProvidersByKey) Kind() pd3.Kind { func (x ProvidersByKey) LookupByString(key string) (pd3.Node, error) { switch key { - case "Key": + case "Key": return x.Key.Node(), nil - case "Provider": + case "Provider": return x.Provider.Node(), nil } @@ -2075,9 +2108,9 @@ func (x ProvidersByKey) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x ProvidersByKey) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Key.Node(), nil - case 1: + case 1: return x.Provider.Node(), nil } @@ -2086,9 +2119,9 @@ func (x ProvidersByKey) LookupByIndex(idx int64) (pd3.Node, error) { func (x ProvidersByKey) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Key": + case "0", "Key": return x.Key.Node(), nil - case "1", "Provider": + case "1", "Provider": return x.Provider.Node(), nil } @@ -2146,7 +2179,8 @@ func (x ProvidersByKey) Prototype() pd3.NodePrototype { // -- protocol type Multihash -- type Multihash struct { - Bytes pd1.Bytes + Bytes pd1.Bytes + } func (x Multihash) Node() pd3.Node { @@ -2159,7 +2193,8 @@ func (x *Multihash) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Bytes": x.Bytes.Parse, + "Bytes": x.Bytes.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2170,14 +2205,14 @@ func (x *Multihash) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Bytes": - if _, notParsed := fieldMap["Bytes"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Bytes") - } - if err := x.Bytes.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Bytes") + case "Bytes": + if _, notParsed := fieldMap["Bytes"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Bytes") + } + if err := x.Bytes.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Bytes") } } @@ -2199,15 +2234,15 @@ type Multihash_MapIterator struct { func (x *Multihash_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Bytes"), x.s.Bytes.Node(), nil + case 0: + return pd1.String("Bytes"), x.s.Bytes.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Multihash_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } func (x Multihash) Kind() pd3.Kind { @@ -2216,7 +2251,7 @@ func (x Multihash) Kind() pd3.Kind { func (x Multihash) LookupByString(key string) (pd3.Node, error) { switch key { - case "Bytes": + case "Bytes": return x.Bytes.Node(), nil } @@ -2243,7 +2278,7 @@ func (x Multihash) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Multihash) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Bytes.Node(), nil } @@ -2252,7 +2287,7 @@ func (x Multihash) LookupByIndex(idx int64) (pd3.Node, error) { func (x Multihash) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Bytes": + case "0", "Bytes": return x.Bytes.Node(), nil } @@ -2430,7 +2465,6 @@ func (iter *AnonList13_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList13_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type AnonList14 -- type AnonList14 []TransferProto @@ -2554,12 +2588,12 @@ func (iter *AnonList14_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList14_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type Provider -- type Provider struct { - Nodes AnonList13 - Proto AnonList14 + Nodes AnonList13 + Proto AnonList14 + } func (x Provider) Node() pd3.Node { @@ -2572,8 +2606,9 @@ func (x *Provider) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Nodes": x.Nodes.Parse, + "Nodes": x.Nodes.Parse, "Proto": x.Proto.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2584,22 +2619,22 @@ func (x *Provider) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Nodes": - if _, notParsed := fieldMap["Nodes"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Nodes") - } - if err := x.Nodes.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Nodes") - case "Proto": - if _, notParsed := fieldMap["Proto"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Proto") - } - if err := x.Proto.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Proto") + case "Nodes": + if _, notParsed := fieldMap["Nodes"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Nodes") + } + if err := x.Nodes.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Nodes") + case "Proto": + if _, notParsed := fieldMap["Proto"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Proto") + } + if err := x.Proto.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Proto") } } @@ -2621,17 +2656,17 @@ type Provider_MapIterator struct { func (x *Provider_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Nodes"), x.s.Nodes.Node(), nil - case 1: - return pd1.String("Proto"), x.s.Proto.Node(), nil + case 0: + return pd1.String("Nodes"), x.s.Nodes.Node(), nil + case 1: + return pd1.String("Proto"), x.s.Proto.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Provider_MapIterator) Done() bool { - return x.i+1 >= 2 + return x.i + 1 >= 2 } func (x Provider) Kind() pd3.Kind { @@ -2640,9 +2675,9 @@ func (x Provider) Kind() pd3.Kind { func (x Provider) LookupByString(key string) (pd3.Node, error) { switch key { - case "Nodes": + case "Nodes": return x.Nodes.Node(), nil - case "Proto": + case "Proto": return x.Proto.Node(), nil } @@ -2669,9 +2704,9 @@ func (x Provider) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Provider) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Nodes.Node(), nil - case 1: + case 1: return x.Proto.Node(), nil } @@ -2680,9 +2715,9 @@ func (x Provider) LookupByIndex(idx int64) (pd3.Node, error) { func (x Provider) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Nodes": + case "0", "Nodes": return x.Nodes.Node(), nil - case "1", "Proto": + case "1", "Proto": return x.Proto.Node(), nil } @@ -2740,7 +2775,9 @@ func (x Provider) Prototype() pd3.NodePrototype { // -- protocol type Node -- type Node struct { - Peer *Peer + Peer *Peer + + } func (x *Node) Parse(n pd3.Node) error { @@ -2766,6 +2803,7 @@ func (x *Node) Parse(n pd3.Node) error { x.Peer = &y return nil + } return pd2.Errorf("inductive map has no applicable keys") @@ -2783,9 +2821,10 @@ func (x *Node_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { } else { x.done = true switch { - case x.s.Peer != nil: + case x.s.Peer != nil: return pd1.String("Peer"), x.s.Peer.Node(), nil + default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -2806,9 +2845,10 @@ func (x Node) Kind() pd3.Kind { func (x Node) LookupByString(key string) (pd3.Node, error) { switch { - case x.Peer != nil && key == "Peer": + case x.Peer != nil && key == "Peer": return x.Peer.Node(), nil + } return nil, pd1.ErrNA } @@ -2830,9 +2870,10 @@ func (x Node) LookupByIndex(idx int64) (pd3.Node, error) { func (x Node) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "Peer": + case "Peer": return x.Peer.Node(), nil + } return nil, pd1.ErrNA } @@ -2884,7 +2925,6 @@ func (x Node) AsLink() (pd3.Link, error) { func (x Node) Prototype() pd3.NodePrototype { return nil } - // -- protocol type AnonList17 -- type AnonList17 []pd1.Bytes @@ -3008,12 +3048,12 @@ func (iter *AnonList17_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList17_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type Peer -- type Peer struct { - ID pd1.Bytes - Multiaddresses AnonList17 + ID pd1.Bytes + Multiaddresses AnonList17 + } func (x Peer) Node() pd3.Node { @@ -3026,8 +3066,9 @@ func (x *Peer) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "ID": x.ID.Parse, + "ID": x.ID.Parse, "Multiaddresses": x.Multiaddresses.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -3038,22 +3079,22 @@ func (x *Peer) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "ID": - if _, notParsed := fieldMap["ID"]; !notParsed { - return pd2.Errorf("field %s already parsed", "ID") - } - if err := x.ID.Parse(vn); err != nil { - return err - } - delete(fieldMap, "ID") - case "Multiaddresses": - if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Multiaddresses") - } - if err := x.Multiaddresses.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Multiaddresses") + case "ID": + if _, notParsed := fieldMap["ID"]; !notParsed { + return pd2.Errorf("field %s already parsed", "ID") + } + if err := x.ID.Parse(vn); err != nil { + return err + } + delete(fieldMap, "ID") + case "Multiaddresses": + if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Multiaddresses") + } + if err := x.Multiaddresses.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Multiaddresses") } } @@ -3075,17 +3116,17 @@ type Peer_MapIterator struct { func (x *Peer_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("ID"), x.s.ID.Node(), nil - case 1: - return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil + case 0: + return pd1.String("ID"), x.s.ID.Node(), nil + case 1: + return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Peer_MapIterator) Done() bool { - return x.i+1 >= 2 + return x.i + 1 >= 2 } func (x Peer) Kind() pd3.Kind { @@ -3094,9 +3135,9 @@ func (x Peer) Kind() pd3.Kind { func (x Peer) LookupByString(key string) (pd3.Node, error) { switch key { - case "ID": + case "ID": return x.ID.Node(), nil - case "Multiaddresses": + case "Multiaddresses": return x.Multiaddresses.Node(), nil } @@ -3123,9 +3164,9 @@ func (x Peer) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Peer) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.ID.Node(), nil - case 1: + case 1: return x.Multiaddresses.Node(), nil } @@ -3134,9 +3175,9 @@ func (x Peer) LookupByIndex(idx int64) (pd3.Node, error) { func (x Peer) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "ID": + case "0", "ID": return x.ID.Node(), nil - case "1", "Multiaddresses": + case "1", "Multiaddresses": return x.Multiaddresses.Node(), nil } @@ -3194,7 +3235,9 @@ func (x Peer) Prototype() pd3.NodePrototype { // -- protocol type TransferProto -- type TransferProto struct { - Bitswap *BitswapTransfer + Bitswap *BitswapTransfer + + } func (x *TransferProto) Parse(n pd3.Node) error { @@ -3220,6 +3263,7 @@ func (x *TransferProto) Parse(n pd3.Node) error { x.Bitswap = &y return nil + } return pd2.Errorf("inductive map has no applicable keys") @@ -3237,9 +3281,10 @@ func (x *TransferProto_MapIterator) Next() (key pd3.Node, value pd3.Node, err er } else { x.done = true switch { - case x.s.Bitswap != nil: + case x.s.Bitswap != nil: return pd1.String("Bitswap"), x.s.Bitswap.Node(), nil + default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -3260,9 +3305,10 @@ func (x TransferProto) Kind() pd3.Kind { func (x TransferProto) LookupByString(key string) (pd3.Node, error) { switch { - case x.Bitswap != nil && key == "Bitswap": + case x.Bitswap != nil && key == "Bitswap": return x.Bitswap.Node(), nil + } return nil, pd1.ErrNA } @@ -3284,9 +3330,10 @@ func (x TransferProto) LookupByIndex(idx int64) (pd3.Node, error) { func (x TransferProto) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "Bitswap": + case "Bitswap": return x.Bitswap.Node(), nil + } return nil, pd1.ErrNA } @@ -3338,10 +3385,10 @@ func (x TransferProto) AsLink() (pd3.Link, error) { func (x TransferProto) Prototype() pd3.NodePrototype { return nil } - // -- protocol type BitswapTransfer -- type BitswapTransfer struct { + } func (x BitswapTransfer) Node() pd3.Node { @@ -3353,7 +3400,9 @@ func (x *BitswapTransfer) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{ + + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -3390,7 +3439,7 @@ func (x *BitswapTransfer_MapIterator) Next() (key pd3.Node, value pd3.Node, err } func (x *BitswapTransfer_MapIterator) Done() bool { - return x.i+1 >= 0 + return x.i + 1 >= 0 } func (x BitswapTransfer) Kind() pd3.Kind { diff --git a/examples/greeting-service/api/proto/proto_edelweiss.go b/examples/greeting-service/api/proto/proto_edelweiss.go index 49eb1be..4a064de 100644 --- a/examples/greeting-service/api/proto/proto_edelweiss.go +++ b/examples/greeting-service/api/proto/proto_edelweiss.go @@ -2,26 +2,28 @@ package proto -import ( - pd6 "bytes" - pd7 "context" - pd9 "errors" +import( + pd1 "github.com/ipld/edelweiss/values" pd2 "fmt" + pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd4 "net/http" pd5 "github.com/ipfs/go-log/v2" - pd13 "github.com/ipld/edelweiss/services" - pd1 "github.com/ipld/edelweiss/values" - pd11 "github.com/ipld/go-ipld-prime" + pd6 "bytes" + pd7 "context" pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" - pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd9 "errors" pd10 "io" - pd4 "net/http" + pd11 "github.com/ipld/go-ipld-prime" pd12 "net/url" + pd13 "github.com/ipld/edelweiss/services" pd14 "sync" ) + // -- protocol type GreetingService_IdentifyArg -- type GreetingService_IdentifyArg struct { + } func (x GreetingService_IdentifyArg) Node() pd3.Node { @@ -33,7 +35,9 @@ func (x *GreetingService_IdentifyArg) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{ + + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -70,7 +74,7 @@ func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd3.Node, value pd } func (x *GreetingService_IdentifyArg_MapIterator) Done() bool { - return x.i+1 >= 0 + return x.i + 1 >= 0 } func (x GreetingService_IdentifyArg) Kind() pd3.Kind { @@ -287,11 +291,11 @@ func (iter *AnonList1_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList1_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type GreetingService_IdentifyResult -- type GreetingService_IdentifyResult struct { - Methods AnonList1 + Methods AnonList1 + } func (x GreetingService_IdentifyResult) Node() pd3.Node { @@ -304,7 +308,8 @@ func (x *GreetingService_IdentifyResult) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Methods": x.Methods.Parse, + "Methods": x.Methods.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -315,14 +320,14 @@ func (x *GreetingService_IdentifyResult) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Methods": - if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Methods") - } - if err := x.Methods.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Methods") + case "Methods": + if _, notParsed := fieldMap["Methods"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Methods") + } + if err := x.Methods.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Methods") } } @@ -344,15 +349,15 @@ type GreetingService_IdentifyResult_MapIterator struct { func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Methods"), x.s.Methods.Node(), nil + case 0: + return pd1.String("Methods"), x.s.Methods.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GreetingService_IdentifyResult_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } func (x GreetingService_IdentifyResult) Kind() pd3.Kind { @@ -361,7 +366,7 @@ func (x GreetingService_IdentifyResult) Kind() pd3.Kind { func (x GreetingService_IdentifyResult) LookupByString(key string) (pd3.Node, error) { switch key { - case "Methods": + case "Methods": return x.Methods.Node(), nil } @@ -388,7 +393,7 @@ func (x GreetingService_IdentifyResult) LookupByNode(key pd3.Node) (pd3.Node, er func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Methods.Node(), nil } @@ -397,7 +402,7 @@ func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, erro func (x GreetingService_IdentifyResult) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Methods": + case "0", "Methods": return x.Methods.Node(), nil } @@ -455,7 +460,8 @@ func (x GreetingService_IdentifyResult) Prototype() pd3.NodePrototype { // -- protocol type GreetingService_Error -- type GreetingService_Error struct { - Code pd1.String + Code pd1.String + } func (x GreetingService_Error) Node() pd3.Node { @@ -468,7 +474,8 @@ func (x *GreetingService_Error) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Code": x.Code.Parse, + "Code": x.Code.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -479,14 +486,14 @@ func (x *GreetingService_Error) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Code": - if _, notParsed := fieldMap["Code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Code") - } - if err := x.Code.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Code") + case "Code": + if _, notParsed := fieldMap["Code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Code") + } + if err := x.Code.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Code") } } @@ -508,15 +515,15 @@ type GreetingService_Error_MapIterator struct { func (x *GreetingService_Error_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Code"), x.s.Code.Node(), nil + case 0: + return pd1.String("Code"), x.s.Code.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GreetingService_Error_MapIterator) Done() bool { - return x.i+1 >= 1 + return x.i + 1 >= 1 } func (x GreetingService_Error) Kind() pd3.Kind { @@ -525,7 +532,7 @@ func (x GreetingService_Error) Kind() pd3.Kind { func (x GreetingService_Error) LookupByString(key string) (pd3.Node, error) { switch key { - case "Code": + case "Code": return x.Code.Node(), nil } @@ -552,7 +559,7 @@ func (x GreetingService_Error) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GreetingService_Error) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Code.Node(), nil } @@ -561,7 +568,7 @@ func (x GreetingService_Error) LookupByIndex(idx int64) (pd3.Node, error) { func (x GreetingService_Error) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Code": + case "0", "Code": return x.Code.Node(), nil } @@ -619,8 +626,10 @@ func (x GreetingService_Error) Prototype() pd3.NodePrototype { // -- protocol type AnonInductive4 -- type AnonInductive4 struct { - Identify *GreetingService_IdentifyArg - Hello *HelloRequest + Identify *GreetingService_IdentifyArg + Hello *HelloRequest + + } func (x *AnonInductive4) Parse(n pd3.Node) error { @@ -653,6 +662,7 @@ func (x *AnonInductive4) Parse(n pd3.Node) error { x.Hello = &y return nil + } return pd2.Errorf("inductive map has no applicable keys") @@ -670,11 +680,12 @@ func (x *AnonInductive4_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil - case x.s.Hello != nil: + case x.s.Hello != nil: return pd1.String("HelloRequest"), x.s.Hello.Node(), nil + default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -695,11 +706,12 @@ func (x AnonInductive4) Kind() pd3.Kind { func (x AnonInductive4) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyRequest": + case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil - case x.Hello != nil && key == "HelloRequest": + case x.Hello != nil && key == "HelloRequest": return x.Hello.Node(), nil + } return nil, pd1.ErrNA } @@ -721,11 +733,12 @@ func (x AnonInductive4) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive4) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyRequest": + case "IdentifyRequest": return x.Identify.Node(), nil - case "HelloRequest": + case "HelloRequest": return x.Hello.Node(), nil + } return nil, pd1.ErrNA } @@ -777,13 +790,14 @@ func (x AnonInductive4) AsLink() (pd3.Link, error) { func (x AnonInductive4) Prototype() pd3.NodePrototype { return nil } - // -- protocol type AnonInductive5 -- type AnonInductive5 struct { - Identify *GreetingService_IdentifyResult - Hello *HelloResponse - Error *GreetingService_Error + Identify *GreetingService_IdentifyResult + Hello *HelloResponse + Error *GreetingService_Error + + } func (x *AnonInductive5) Parse(n pd3.Node) error { @@ -823,6 +837,7 @@ func (x *AnonInductive5) Parse(n pd3.Node) error { x.Error = &y return nil + } return pd2.Errorf("inductive map has no applicable keys") @@ -840,13 +855,14 @@ func (x *AnonInductive5_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil - case x.s.Hello != nil: + case x.s.Hello != nil: return pd1.String("HelloResponse"), x.s.Hello.Node(), nil - case x.s.Error != nil: + case x.s.Error != nil: return pd1.String("Error"), x.s.Error.Node(), nil + default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -867,13 +883,14 @@ func (x AnonInductive5) Kind() pd3.Kind { func (x AnonInductive5) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyResponse": + case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil - case x.Hello != nil && key == "HelloResponse": + case x.Hello != nil && key == "HelloResponse": return x.Hello.Node(), nil - case x.Error != nil && key == "Error": + case x.Error != nil && key == "Error": return x.Error.Node(), nil + } return nil, pd1.ErrNA } @@ -895,13 +912,14 @@ func (x AnonInductive5) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive5) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyResponse": + case "IdentifyResponse": return x.Identify.Node(), nil - case "HelloResponse": + case "HelloResponse": return x.Hello.Node(), nil - case "Error": + case "Error": return x.Error.Node(), nil + } return nil, pd1.ErrNA } @@ -953,19 +971,22 @@ func (x AnonInductive5) AsLink() (pd3.Link, error) { func (x AnonInductive5) Prototype() pd3.NodePrototype { return nil } - var logger_client_GreetingService = pd5.Logger("service/client/greetingservice") type GreetingService_Client interface { - Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) - Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) +Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) + +Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) + - Identify_Async(ctx pd7.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) +Identify_Async(ctx pd7.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) + +Hello_Async(ctx pd7.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) - Hello_Async(ctx pd7.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) } + type GreetingService_Identify_AsyncResult struct { Resp *GreetingService_IdentifyResult Err error @@ -976,12 +997,13 @@ type GreetingService_Hello_AsyncResult struct { Err error } + type GreetingService_ClientOption func(*client_GreetingService) error type client_GreetingService struct { - httpClient *pd4.Client - endpoint *pd12.URL - ulk pd14.Mutex + httpClient *pd4.Client + endpoint *pd12.URL + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } @@ -1006,6 +1028,8 @@ func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientO return c, nil } + + func (c *client_GreetingService) Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1104,8 +1128,8 @@ func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- Gre defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1138,13 +1162,14 @@ func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- Gre } select { - case <-ctx.Done(): - return - case ch <- out: + case <- ctx.Done(): + return + case ch <- out: } } } + func (c *client_GreetingService) Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1243,8 +1268,8 @@ func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- Greeti defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1277,16 +1302,18 @@ func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- Greeti } select { - case <-ctx.Done(): - return - case ch <- out: + case <- ctx.Done(): + return + case ch <- out: } } } + var logger_server_GreetingService = pd5.Logger("service/server/greetingservice") type GreetingService_Server interface { + Hello(ctx pd7.Context, req *HelloRequest) (<-chan *GreetingService_Hello_AsyncResult, error) } @@ -1343,9 +1370,9 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { } var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())}} + env = &AnonInductive5{ Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())} } } else { - env = &AnonInductive5{Hello: resp.Resp} + env = &AnonInductive5{ Hello: resp.Resp } } var buf pd6.Buffer if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { @@ -1360,12 +1387,14 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { } } + case env.Identify != nil: var env *AnonInductive5 env = &AnonInductive5{ Identify: &GreetingService_IdentifyResult{ Methods: []pd1.String{ "Hello", + }, }, } @@ -1388,8 +1417,9 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { // -- protocol type HelloRequest -- type HelloRequest struct { - Name pd1.String - Address Address + Name pd1.String + Address Address + } func (x HelloRequest) Node() pd3.Node { @@ -1402,8 +1432,9 @@ func (x *HelloRequest) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Name": x.Name.Parse, + "Name": x.Name.Parse, "Address": x.Address.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1414,22 +1445,22 @@ func (x *HelloRequest) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Name": - if _, notParsed := fieldMap["Name"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Name") - } - if err := x.Name.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Name") - case "Address": - if _, notParsed := fieldMap["Address"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Address") - } - if err := x.Address.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Address") + case "Name": + if _, notParsed := fieldMap["Name"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Name") + } + if err := x.Name.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Name") + case "Address": + if _, notParsed := fieldMap["Address"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Address") + } + if err := x.Address.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Address") } } @@ -1451,17 +1482,17 @@ type HelloRequest_MapIterator struct { func (x *HelloRequest_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Name"), x.s.Name.Node(), nil - case 1: - return pd1.String("Address"), x.s.Address.Node(), nil + case 0: + return pd1.String("Name"), x.s.Name.Node(), nil + case 1: + return pd1.String("Address"), x.s.Address.Node(), nil } return nil, nil, pd1.ErrNA } func (x *HelloRequest_MapIterator) Done() bool { - return x.i+1 >= 2 + return x.i + 1 >= 2 } func (x HelloRequest) Kind() pd3.Kind { @@ -1470,9 +1501,9 @@ func (x HelloRequest) Kind() pd3.Kind { func (x HelloRequest) LookupByString(key string) (pd3.Node, error) { switch key { - case "Name": + case "Name": return x.Name.Node(), nil - case "Address": + case "Address": return x.Address.Node(), nil } @@ -1499,9 +1530,9 @@ func (x HelloRequest) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x HelloRequest) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Name.Node(), nil - case 1: + case 1: return x.Address.Node(), nil } @@ -1510,9 +1541,9 @@ func (x HelloRequest) LookupByIndex(idx int64) (pd3.Node, error) { func (x HelloRequest) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Name": + case "0", "Name": return x.Name.Node(), nil - case "1", "Address": + case "1", "Address": return x.Address.Node(), nil } @@ -1690,15 +1721,16 @@ func (iter *AddressLines_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AddressLines_ListIterator) Done() bool { return iter.at >= iter.list.Length() } - // -- protocol type Address -- type Address struct { - US *USAddress - SK *SKAddress + US *USAddress + SK *SKAddress + + + OtherCountry string + OtherAddress *AddressLines - OtherCountry string - OtherAddress *AddressLines } func (x *Address) Parse(n pd3.Node) error { @@ -1731,6 +1763,7 @@ func (x *Address) Parse(n pd3.Node) error { x.SK = &y return nil + default: var y AddressLines if err := y.Parse(vn); err != nil { @@ -1755,13 +1788,14 @@ func (x *Address_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { } else { x.done = true switch { - case x.s.US != nil: + case x.s.US != nil: return pd1.String("US"), x.s.US.Node(), nil - case x.s.SK != nil: + case x.s.SK != nil: return pd1.String("SouthKorea"), x.s.SK.Node(), nil - case x.s.OtherAddress != nil: - return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil + + case x.s.OtherAddress != nil: + return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil default: return nil, nil, pd2.Errorf("no inductive cases are set") @@ -1783,11 +1817,12 @@ func (x Address) Kind() pd3.Kind { func (x Address) LookupByString(key string) (pd3.Node, error) { switch { - case x.US != nil && key == "US": + case x.US != nil && key == "US": return x.US.Node(), nil - case x.SK != nil && key == "SouthKorea": + case x.SK != nil && key == "SouthKorea": return x.SK.Node(), nil + case x.OtherAddress != nil && key == x.OtherCountry: return x.OtherAddress.Node(), nil @@ -1812,11 +1847,12 @@ func (x Address) LookupByIndex(idx int64) (pd3.Node, error) { func (x Address) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "US": + case "US": return x.US.Node(), nil - case "SouthKorea": + case "SouthKorea": return x.SK.Node(), nil + case x.OtherCountry: return x.OtherAddress.Node(), nil @@ -1871,14 +1907,14 @@ func (x Address) AsLink() (pd3.Link, error) { func (x Address) Prototype() pd3.NodePrototype { return nil } - // -- protocol type USAddress -- type USAddress struct { - Street pd1.String - City pd1.String - State State - ZIP pd1.Int + Street pd1.String + City pd1.String + State State + ZIP pd1.Int + } func (x USAddress) Node() pd3.Node { @@ -1891,10 +1927,11 @@ func (x *USAddress) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "street": x.Street.Parse, - "city": x.City.Parse, - "state": x.State.Parse, - "zip": x.ZIP.Parse, + "street": x.Street.Parse, + "city": x.City.Parse, + "state": x.State.Parse, + "zip": x.ZIP.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1905,38 +1942,38 @@ func (x *USAddress) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "street": - if _, notParsed := fieldMap["street"]; !notParsed { - return pd2.Errorf("field %s already parsed", "street") - } - if err := x.Street.Parse(vn); err != nil { - return err - } - delete(fieldMap, "street") - case "city": - if _, notParsed := fieldMap["city"]; !notParsed { - return pd2.Errorf("field %s already parsed", "city") - } - if err := x.City.Parse(vn); err != nil { - return err - } - delete(fieldMap, "city") - case "state": - if _, notParsed := fieldMap["state"]; !notParsed { - return pd2.Errorf("field %s already parsed", "state") - } - if err := x.State.Parse(vn); err != nil { - return err - } - delete(fieldMap, "state") - case "zip": - if _, notParsed := fieldMap["zip"]; !notParsed { - return pd2.Errorf("field %s already parsed", "zip") - } - if err := x.ZIP.Parse(vn); err != nil { - return err - } - delete(fieldMap, "zip") + case "street": + if _, notParsed := fieldMap["street"]; !notParsed { + return pd2.Errorf("field %s already parsed", "street") + } + if err := x.Street.Parse(vn); err != nil { + return err + } + delete(fieldMap, "street") + case "city": + if _, notParsed := fieldMap["city"]; !notParsed { + return pd2.Errorf("field %s already parsed", "city") + } + if err := x.City.Parse(vn); err != nil { + return err + } + delete(fieldMap, "city") + case "state": + if _, notParsed := fieldMap["state"]; !notParsed { + return pd2.Errorf("field %s already parsed", "state") + } + if err := x.State.Parse(vn); err != nil { + return err + } + delete(fieldMap, "state") + case "zip": + if _, notParsed := fieldMap["zip"]; !notParsed { + return pd2.Errorf("field %s already parsed", "zip") + } + if err := x.ZIP.Parse(vn); err != nil { + return err + } + delete(fieldMap, "zip") } } @@ -1958,21 +1995,21 @@ type USAddress_MapIterator struct { func (x *USAddress_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("street"), x.s.Street.Node(), nil - case 1: - return pd1.String("city"), x.s.City.Node(), nil - case 2: - return pd1.String("state"), x.s.State.Node(), nil - case 3: - return pd1.String("zip"), x.s.ZIP.Node(), nil + case 0: + return pd1.String("street"), x.s.Street.Node(), nil + case 1: + return pd1.String("city"), x.s.City.Node(), nil + case 2: + return pd1.String("state"), x.s.State.Node(), nil + case 3: + return pd1.String("zip"), x.s.ZIP.Node(), nil } return nil, nil, pd1.ErrNA } func (x *USAddress_MapIterator) Done() bool { - return x.i+1 >= 4 + return x.i + 1 >= 4 } func (x USAddress) Kind() pd3.Kind { @@ -1981,13 +2018,13 @@ func (x USAddress) Kind() pd3.Kind { func (x USAddress) LookupByString(key string) (pd3.Node, error) { switch key { - case "street": + case "street": return x.Street.Node(), nil - case "city": + case "city": return x.City.Node(), nil - case "state": + case "state": return x.State.Node(), nil - case "zip": + case "zip": return x.ZIP.Node(), nil } @@ -2014,13 +2051,13 @@ func (x USAddress) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x USAddress) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Street.Node(), nil - case 1: + case 1: return x.City.Node(), nil - case 2: + case 2: return x.State.Node(), nil - case 3: + case 3: return x.ZIP.Node(), nil } @@ -2029,13 +2066,13 @@ func (x USAddress) LookupByIndex(idx int64) (pd3.Node, error) { func (x USAddress) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "street": + case "0", "street": return x.Street.Node(), nil - case "1", "city": + case "1", "city": return x.City.Node(), nil - case "2", "state": + case "2", "state": return x.State.Node(), nil - case "3", "zip": + case "3", "zip": return x.ZIP.Node(), nil } @@ -2273,31 +2310,32 @@ func (StateNY) Prototype() pd3.NodePrototype { // -- protocol type State -- type State struct { - CA *StateCA - NY *StateNY - Other *pd1.String + CA *StateCA + NY *StateNY + Other *pd1.String + } func (x *State) Parse(n pd3.Node) error { *x = State{} - - var CA StateCA - if err := CA.Parse(n); err == nil { - x.CA = &CA - return nil - } - - var NY StateNY - if err := NY.Parse(n); err == nil { - x.NY = &NY - return nil - } - - var Other pd1.String - if err := Other.Parse(n); err == nil { - x.Other = &Other - return nil - } + + var CA StateCA + if err := CA.Parse(n); err == nil { + x.CA = &CA + return nil + } + + var NY StateNY + if err := NY.Parse(n); err == nil { + x.NY = &NY + return nil + } + + var Other pd1.String + if err := Other.Parse(n); err == nil { + x.Other = &Other + return nil + } return pd2.Errorf("no union cases parses") } @@ -2319,225 +2357,129 @@ func (x State) Node() pd3.Node { // proxy Node methods to active case func (x State) Kind() pd3.Kind { - if x.CA != nil { - return x.CA.Kind() - } - if x.NY != nil { - return x.NY.Kind() - } - if x.Other != nil { - return x.Other.Kind() - } + if x.CA != nil { return x.CA.Kind() } + if x.NY != nil { return x.NY.Kind() } + if x.Other != nil { return x.Other.Kind() } return pd3.Kind_Invalid } func (x State) LookupByString(key string) (pd3.Node, error) { - if x.CA != nil { - return x.CA.LookupByString(key) - } - if x.NY != nil { - return x.NY.LookupByString(key) - } - if x.Other != nil { - return x.Other.LookupByString(key) - } + if x.CA != nil { return x.CA.LookupByString(key) } + if x.NY != nil { return x.NY.LookupByString(key) } + if x.Other != nil { return x.Other.LookupByString(key) } return nil, pd2.Errorf("no active union case found") } func (x State) LookupByNode(key pd3.Node) (pd3.Node, error) { - if x.CA != nil { - return x.CA.LookupByNode(key) - } - if x.NY != nil { - return x.NY.LookupByNode(key) - } - if x.Other != nil { - return x.Other.LookupByNode(key) - } + if x.CA != nil { return x.CA.LookupByNode(key) } + if x.NY != nil { return x.NY.LookupByNode(key) } + if x.Other != nil { return x.Other.LookupByNode(key) } return nil, pd2.Errorf("no active union case found") } func (x State) LookupByIndex(idx int64) (pd3.Node, error) { - if x.CA != nil { - return x.CA.LookupByIndex(idx) - } - if x.NY != nil { - return x.NY.LookupByIndex(idx) - } - if x.Other != nil { - return x.Other.LookupByIndex(idx) - } + if x.CA != nil { return x.CA.LookupByIndex(idx) } + if x.NY != nil { return x.NY.LookupByIndex(idx) } + if x.Other != nil { return x.Other.LookupByIndex(idx) } return nil, pd2.Errorf("no active union case found") } func (x State) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { - if x.CA != nil { - return x.CA.LookupBySegment(seg) - } - if x.NY != nil { - return x.NY.LookupBySegment(seg) - } - if x.Other != nil { - return x.Other.LookupBySegment(seg) - } + if x.CA != nil { return x.CA.LookupBySegment(seg) } + if x.NY != nil { return x.NY.LookupBySegment(seg) } + if x.Other != nil { return x.Other.LookupBySegment(seg) } return nil, pd2.Errorf("no active union case found") } func (x State) MapIterator() pd3.MapIterator { - if x.CA != nil { - return x.CA.MapIterator() - } - if x.NY != nil { - return x.NY.MapIterator() - } - if x.Other != nil { - return x.Other.MapIterator() - } + if x.CA != nil { return x.CA.MapIterator() } + if x.NY != nil { return x.NY.MapIterator() } + if x.Other != nil { return x.Other.MapIterator() } return nil } func (x State) ListIterator() pd3.ListIterator { - if x.CA != nil { - return x.CA.ListIterator() - } - if x.NY != nil { - return x.NY.ListIterator() - } - if x.Other != nil { - return x.Other.ListIterator() - } + if x.CA != nil { return x.CA.ListIterator() } + if x.NY != nil { return x.NY.ListIterator() } + if x.Other != nil { return x.Other.ListIterator() } return nil } func (x State) Length() int64 { - if x.CA != nil { - return x.CA.Length() - } - if x.NY != nil { - return x.NY.Length() - } - if x.Other != nil { - return x.Other.Length() - } + if x.CA != nil { return x.CA.Length() } + if x.NY != nil { return x.NY.Length() } + if x.Other != nil { return x.Other.Length() } return -1 } func (x State) IsAbsent() bool { - if x.CA != nil { - return x.CA.IsAbsent() - } - if x.NY != nil { - return x.NY.IsAbsent() - } - if x.Other != nil { - return x.Other.IsAbsent() - } + if x.CA != nil { return x.CA.IsAbsent() } + if x.NY != nil { return x.NY.IsAbsent() } + if x.Other != nil { return x.Other.IsAbsent() } return false } func (x State) IsNull() bool { - if x.CA != nil { - return x.CA.IsNull() - } - if x.NY != nil { - return x.NY.IsNull() - } - if x.Other != nil { - return x.Other.IsNull() - } + if x.CA != nil { return x.CA.IsNull() } + if x.NY != nil { return x.NY.IsNull() } + if x.Other != nil { return x.Other.IsNull() } return false } func (x State) AsBool() (bool, error) { - if x.CA != nil { - return x.CA.AsBool() - } - if x.NY != nil { - return x.NY.AsBool() - } - if x.Other != nil { - return x.Other.AsBool() - } + if x.CA != nil { return x.CA.AsBool() } + if x.NY != nil { return x.NY.AsBool() } + if x.Other != nil { return x.Other.AsBool() } return false, pd2.Errorf("no active union case found") } func (x State) AsInt() (int64, error) { - if x.CA != nil { - return x.CA.AsInt() - } - if x.NY != nil { - return x.NY.AsInt() - } - if x.Other != nil { - return x.Other.AsInt() - } + if x.CA != nil { return x.CA.AsInt() } + if x.NY != nil { return x.NY.AsInt() } + if x.Other != nil { return x.Other.AsInt() } return 0, pd2.Errorf("no active union case found") } func (x State) AsFloat() (float64, error) { - if x.CA != nil { - return x.CA.AsFloat() - } - if x.NY != nil { - return x.NY.AsFloat() - } - if x.Other != nil { - return x.Other.AsFloat() - } + if x.CA != nil { return x.CA.AsFloat() } + if x.NY != nil { return x.NY.AsFloat() } + if x.Other != nil { return x.Other.AsFloat() } return 0.0, pd2.Errorf("no active union case found") } func (x State) AsString() (string, error) { - if x.CA != nil { - return x.CA.AsString() - } - if x.NY != nil { - return x.NY.AsString() - } - if x.Other != nil { - return x.Other.AsString() - } + if x.CA != nil { return x.CA.AsString() } + if x.NY != nil { return x.NY.AsString() } + if x.Other != nil { return x.Other.AsString() } return "", pd2.Errorf("no active union case found") } func (x State) AsBytes() ([]byte, error) { - if x.CA != nil { - return x.CA.AsBytes() - } - if x.NY != nil { - return x.NY.AsBytes() - } - if x.Other != nil { - return x.Other.AsBytes() - } + if x.CA != nil { return x.CA.AsBytes() } + if x.NY != nil { return x.NY.AsBytes() } + if x.Other != nil { return x.Other.AsBytes() } return nil, pd2.Errorf("no active union case found") } func (x State) AsLink() (pd3.Link, error) { - if x.CA != nil { - return x.CA.AsLink() - } - if x.NY != nil { - return x.NY.AsLink() - } - if x.Other != nil { - return x.Other.AsLink() - } + if x.CA != nil { return x.CA.AsLink() } + if x.NY != nil { return x.NY.AsLink() } + if x.Other != nil { return x.Other.AsLink() } return nil, pd2.Errorf("no active union case found") } @@ -2545,14 +2487,14 @@ func (x State) AsLink() (pd3.Link, error) { func (x State) Prototype() pd3.NodePrototype { return nil } - // -- protocol type SKAddress -- type SKAddress struct { - Street pd1.String - City pd1.String - Province pd1.String - PostalCode pd1.Int + Street pd1.String + City pd1.String + Province pd1.String + PostalCode pd1.Int + } func (x SKAddress) Node() pd3.Node { @@ -2565,10 +2507,11 @@ func (x *SKAddress) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "street": x.Street.Parse, - "city": x.City.Parse, - "province": x.Province.Parse, + "street": x.Street.Parse, + "city": x.City.Parse, + "province": x.Province.Parse, "postal_code": x.PostalCode.Parse, + } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2579,38 +2522,38 @@ func (x *SKAddress) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "street": - if _, notParsed := fieldMap["street"]; !notParsed { - return pd2.Errorf("field %s already parsed", "street") - } - if err := x.Street.Parse(vn); err != nil { - return err - } - delete(fieldMap, "street") - case "city": - if _, notParsed := fieldMap["city"]; !notParsed { - return pd2.Errorf("field %s already parsed", "city") - } - if err := x.City.Parse(vn); err != nil { - return err - } - delete(fieldMap, "city") - case "province": - if _, notParsed := fieldMap["province"]; !notParsed { - return pd2.Errorf("field %s already parsed", "province") - } - if err := x.Province.Parse(vn); err != nil { - return err - } - delete(fieldMap, "province") - case "postal_code": - if _, notParsed := fieldMap["postal_code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "postal_code") - } - if err := x.PostalCode.Parse(vn); err != nil { - return err - } - delete(fieldMap, "postal_code") + case "street": + if _, notParsed := fieldMap["street"]; !notParsed { + return pd2.Errorf("field %s already parsed", "street") + } + if err := x.Street.Parse(vn); err != nil { + return err + } + delete(fieldMap, "street") + case "city": + if _, notParsed := fieldMap["city"]; !notParsed { + return pd2.Errorf("field %s already parsed", "city") + } + if err := x.City.Parse(vn); err != nil { + return err + } + delete(fieldMap, "city") + case "province": + if _, notParsed := fieldMap["province"]; !notParsed { + return pd2.Errorf("field %s already parsed", "province") + } + if err := x.Province.Parse(vn); err != nil { + return err + } + delete(fieldMap, "province") + case "postal_code": + if _, notParsed := fieldMap["postal_code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "postal_code") + } + if err := x.PostalCode.Parse(vn); err != nil { + return err + } + delete(fieldMap, "postal_code") } } @@ -2632,21 +2575,21 @@ type SKAddress_MapIterator struct { func (x *SKAddress_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("street"), x.s.Street.Node(), nil - case 1: - return pd1.String("city"), x.s.City.Node(), nil - case 2: - return pd1.String("province"), x.s.Province.Node(), nil - case 3: - return pd1.String("postal_code"), x.s.PostalCode.Node(), nil + case 0: + return pd1.String("street"), x.s.Street.Node(), nil + case 1: + return pd1.String("city"), x.s.City.Node(), nil + case 2: + return pd1.String("province"), x.s.Province.Node(), nil + case 3: + return pd1.String("postal_code"), x.s.PostalCode.Node(), nil } return nil, nil, pd1.ErrNA } func (x *SKAddress_MapIterator) Done() bool { - return x.i+1 >= 4 + return x.i + 1 >= 4 } func (x SKAddress) Kind() pd3.Kind { @@ -2655,13 +2598,13 @@ func (x SKAddress) Kind() pd3.Kind { func (x SKAddress) LookupByString(key string) (pd3.Node, error) { switch key { - case "street": + case "street": return x.Street.Node(), nil - case "city": + case "city": return x.City.Node(), nil - case "province": + case "province": return x.Province.Node(), nil - case "postal_code": + case "postal_code": return x.PostalCode.Node(), nil } @@ -2688,13 +2631,13 @@ func (x SKAddress) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x SKAddress) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Street.Node(), nil - case 1: + case 1: return x.City.Node(), nil - case 2: + case 2: return x.Province.Node(), nil - case 3: + case 3: return x.PostalCode.Node(), nil } @@ -2703,13 +2646,13 @@ func (x SKAddress) LookupByIndex(idx int64) (pd3.Node, error) { func (x SKAddress) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "street": + case "0", "street": return x.Street.Node(), nil - case "1", "city": + case "1", "city": return x.City.Node(), nil - case "2", "province": + case "2", "province": return x.Province.Node(), nil - case "3", "postal_code": + case "3", "postal_code": return x.PostalCode.Node(), nil } @@ -2767,24 +2710,25 @@ func (x SKAddress) Prototype() pd3.NodePrototype { // -- protocol type HelloResponse -- type HelloResponse struct { - English *pd1.String - Korean *pd1.String + English *pd1.String + Korean *pd1.String + } func (x *HelloResponse) Parse(n pd3.Node) error { *x = HelloResponse{} - - var English pd1.String - if err := English.Parse(n); err == nil { - x.English = &English - return nil - } - - var Korean pd1.String - if err := Korean.Parse(n); err == nil { - x.Korean = &Korean - return nil - } + + var English pd1.String + if err := English.Parse(n); err == nil { + x.English = &English + return nil + } + + var Korean pd1.String + if err := Korean.Parse(n); err == nil { + x.Korean = &Korean + return nil + } return pd2.Errorf("no union cases parses") } @@ -2803,181 +2747,117 @@ func (x HelloResponse) Node() pd3.Node { // proxy Node methods to active case func (x HelloResponse) Kind() pd3.Kind { - if x.English != nil { - return x.English.Kind() - } - if x.Korean != nil { - return x.Korean.Kind() - } + if x.English != nil { return x.English.Kind() } + if x.Korean != nil { return x.Korean.Kind() } return pd3.Kind_Invalid } func (x HelloResponse) LookupByString(key string) (pd3.Node, error) { - if x.English != nil { - return x.English.LookupByString(key) - } - if x.Korean != nil { - return x.Korean.LookupByString(key) - } + if x.English != nil { return x.English.LookupByString(key) } + if x.Korean != nil { return x.Korean.LookupByString(key) } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupByNode(key pd3.Node) (pd3.Node, error) { - if x.English != nil { - return x.English.LookupByNode(key) - } - if x.Korean != nil { - return x.Korean.LookupByNode(key) - } + if x.English != nil { return x.English.LookupByNode(key) } + if x.Korean != nil { return x.Korean.LookupByNode(key) } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupByIndex(idx int64) (pd3.Node, error) { - if x.English != nil { - return x.English.LookupByIndex(idx) - } - if x.Korean != nil { - return x.Korean.LookupByIndex(idx) - } + if x.English != nil { return x.English.LookupByIndex(idx) } + if x.Korean != nil { return x.Korean.LookupByIndex(idx) } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { - if x.English != nil { - return x.English.LookupBySegment(seg) - } - if x.Korean != nil { - return x.Korean.LookupBySegment(seg) - } + if x.English != nil { return x.English.LookupBySegment(seg) } + if x.Korean != nil { return x.Korean.LookupBySegment(seg) } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) MapIterator() pd3.MapIterator { - if x.English != nil { - return x.English.MapIterator() - } - if x.Korean != nil { - return x.Korean.MapIterator() - } + if x.English != nil { return x.English.MapIterator() } + if x.Korean != nil { return x.Korean.MapIterator() } return nil } func (x HelloResponse) ListIterator() pd3.ListIterator { - if x.English != nil { - return x.English.ListIterator() - } - if x.Korean != nil { - return x.Korean.ListIterator() - } + if x.English != nil { return x.English.ListIterator() } + if x.Korean != nil { return x.Korean.ListIterator() } return nil } func (x HelloResponse) Length() int64 { - if x.English != nil { - return x.English.Length() - } - if x.Korean != nil { - return x.Korean.Length() - } + if x.English != nil { return x.English.Length() } + if x.Korean != nil { return x.Korean.Length() } return -1 } func (x HelloResponse) IsAbsent() bool { - if x.English != nil { - return x.English.IsAbsent() - } - if x.Korean != nil { - return x.Korean.IsAbsent() - } + if x.English != nil { return x.English.IsAbsent() } + if x.Korean != nil { return x.Korean.IsAbsent() } return false } func (x HelloResponse) IsNull() bool { - if x.English != nil { - return x.English.IsNull() - } - if x.Korean != nil { - return x.Korean.IsNull() - } + if x.English != nil { return x.English.IsNull() } + if x.Korean != nil { return x.Korean.IsNull() } return false } func (x HelloResponse) AsBool() (bool, error) { - if x.English != nil { - return x.English.AsBool() - } - if x.Korean != nil { - return x.Korean.AsBool() - } + if x.English != nil { return x.English.AsBool() } + if x.Korean != nil { return x.Korean.AsBool() } return false, pd2.Errorf("no active union case found") } func (x HelloResponse) AsInt() (int64, error) { - if x.English != nil { - return x.English.AsInt() - } - if x.Korean != nil { - return x.Korean.AsInt() - } + if x.English != nil { return x.English.AsInt() } + if x.Korean != nil { return x.Korean.AsInt() } return 0, pd2.Errorf("no active union case found") } func (x HelloResponse) AsFloat() (float64, error) { - if x.English != nil { - return x.English.AsFloat() - } - if x.Korean != nil { - return x.Korean.AsFloat() - } + if x.English != nil { return x.English.AsFloat() } + if x.Korean != nil { return x.Korean.AsFloat() } return 0.0, pd2.Errorf("no active union case found") } func (x HelloResponse) AsString() (string, error) { - if x.English != nil { - return x.English.AsString() - } - if x.Korean != nil { - return x.Korean.AsString() - } + if x.English != nil { return x.English.AsString() } + if x.Korean != nil { return x.Korean.AsString() } return "", pd2.Errorf("no active union case found") } func (x HelloResponse) AsBytes() ([]byte, error) { - if x.English != nil { - return x.English.AsBytes() - } - if x.Korean != nil { - return x.Korean.AsBytes() - } + if x.English != nil { return x.English.AsBytes() } + if x.Korean != nil { return x.Korean.AsBytes() } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) AsLink() (pd3.Link, error) { - if x.English != nil { - return x.English.AsLink() - } - if x.Korean != nil { - return x.Korean.AsLink() - } + if x.English != nil { return x.English.AsLink() } + if x.Korean != nil { return x.Korean.AsLink() } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) Prototype() pd3.NodePrototype { return nil -} +} \ No newline at end of file From 7485b8da7fa6d4062121b0522a471b6935c87696 Mon Sep 17 00:00:00 2001 From: galargh Date: Thu, 1 Sep 2022 17:54:03 +0200 Subject: [PATCH 4/4] chore: go fmt on examples --- .../gen-routing-api/proto/proto_edelweiss.go | 529 +++++----- .../api/proto/proto_edelweiss.go | 934 ++++++++++-------- 2 files changed, 767 insertions(+), 696 deletions(-) diff --git a/examples/gen-routing-api/proto/proto_edelweiss.go b/examples/gen-routing-api/proto/proto_edelweiss.go index 3bc6f48..69085f9 100644 --- a/examples/gen-routing-api/proto/proto_edelweiss.go +++ b/examples/gen-routing-api/proto/proto_edelweiss.go @@ -2,28 +2,26 @@ package proto -import( - pd1 "github.com/ipld/edelweiss/values" - pd2 "fmt" - pd3 "github.com/ipld/go-ipld-prime/datamodel" - pd4 "net/http" - pd5 "github.com/ipfs/go-log/v2" +import ( pd6 "bytes" pd7 "context" - pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" pd9 "errors" - pd10 "io" + pd2 "fmt" + pd5 "github.com/ipfs/go-log/v2" + pd13 "github.com/ipld/edelweiss/services" + pd1 "github.com/ipld/edelweiss/values" pd11 "github.com/ipld/go-ipld-prime" + pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd10 "io" + pd4 "net/http" pd12 "net/url" - pd13 "github.com/ipld/edelweiss/services" pd14 "sync" ) - // -- protocol type DelegatedRouting_IdentifyArg -- type DelegatedRouting_IdentifyArg struct { - } func (x DelegatedRouting_IdentifyArg) Node() pd3.Node { @@ -35,9 +33,7 @@ func (x *DelegatedRouting_IdentifyArg) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ - - } + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -74,7 +70,7 @@ func (x *DelegatedRouting_IdentifyArg_MapIterator) Next() (key pd3.Node, value p } func (x *DelegatedRouting_IdentifyArg_MapIterator) Done() bool { - return x.i + 1 >= 0 + return x.i+1 >= 0 } func (x DelegatedRouting_IdentifyArg) Kind() pd3.Kind { @@ -291,11 +287,11 @@ func (iter *AnonList1_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList1_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type DelegatedRouting_IdentifyResult -- type DelegatedRouting_IdentifyResult struct { - Methods AnonList1 - + Methods AnonList1 } func (x DelegatedRouting_IdentifyResult) Node() pd3.Node { @@ -308,8 +304,7 @@ func (x *DelegatedRouting_IdentifyResult) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Methods": x.Methods.Parse, - + "Methods": x.Methods.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -320,14 +315,14 @@ func (x *DelegatedRouting_IdentifyResult) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Methods": - if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Methods") - } - if err := x.Methods.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Methods") + case "Methods": + if _, notParsed := fieldMap["Methods"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Methods") + } + if err := x.Methods.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Methods") } } @@ -349,15 +344,15 @@ type DelegatedRouting_IdentifyResult_MapIterator struct { func (x *DelegatedRouting_IdentifyResult_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Methods"), x.s.Methods.Node(), nil + case 0: + return pd1.String("Methods"), x.s.Methods.Node(), nil } return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_IdentifyResult_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x DelegatedRouting_IdentifyResult) Kind() pd3.Kind { @@ -366,7 +361,7 @@ func (x DelegatedRouting_IdentifyResult) Kind() pd3.Kind { func (x DelegatedRouting_IdentifyResult) LookupByString(key string) (pd3.Node, error) { switch key { - case "Methods": + case "Methods": return x.Methods.Node(), nil } @@ -393,7 +388,7 @@ func (x DelegatedRouting_IdentifyResult) LookupByNode(key pd3.Node) (pd3.Node, e func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Methods.Node(), nil } @@ -402,7 +397,7 @@ func (x DelegatedRouting_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, err func (x DelegatedRouting_IdentifyResult) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Methods": + case "0", "Methods": return x.Methods.Node(), nil } @@ -460,8 +455,7 @@ func (x DelegatedRouting_IdentifyResult) Prototype() pd3.NodePrototype { // -- protocol type DelegatedRouting_Error -- type DelegatedRouting_Error struct { - Code pd1.String - + Code pd1.String } func (x DelegatedRouting_Error) Node() pd3.Node { @@ -474,8 +468,7 @@ func (x *DelegatedRouting_Error) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Code": x.Code.Parse, - + "Code": x.Code.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -486,14 +479,14 @@ func (x *DelegatedRouting_Error) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Code": - if _, notParsed := fieldMap["Code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Code") - } - if err := x.Code.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Code") + case "Code": + if _, notParsed := fieldMap["Code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Code") + } + if err := x.Code.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Code") } } @@ -515,15 +508,15 @@ type DelegatedRouting_Error_MapIterator struct { func (x *DelegatedRouting_Error_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Code"), x.s.Code.Node(), nil + case 0: + return pd1.String("Code"), x.s.Code.Node(), nil } return nil, nil, pd1.ErrNA } func (x *DelegatedRouting_Error_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x DelegatedRouting_Error) Kind() pd3.Kind { @@ -532,7 +525,7 @@ func (x DelegatedRouting_Error) Kind() pd3.Kind { func (x DelegatedRouting_Error) LookupByString(key string) (pd3.Node, error) { switch key { - case "Code": + case "Code": return x.Code.Node(), nil } @@ -559,7 +552,7 @@ func (x DelegatedRouting_Error) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Code.Node(), nil } @@ -568,7 +561,7 @@ func (x DelegatedRouting_Error) LookupByIndex(idx int64) (pd3.Node, error) { func (x DelegatedRouting_Error) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Code": + case "0", "Code": return x.Code.Node(), nil } @@ -626,10 +619,8 @@ func (x DelegatedRouting_Error) Prototype() pd3.NodePrototype { // -- protocol type AnonInductive4 -- type AnonInductive4 struct { - Identify *DelegatedRouting_IdentifyArg - GetP2PProvide *GetP2PProvideRequest - - + Identify *DelegatedRouting_IdentifyArg + GetP2PProvide *GetP2PProvideRequest } func (x *AnonInductive4) Parse(n pd3.Node) error { @@ -662,7 +653,6 @@ func (x *AnonInductive4) Parse(n pd3.Node) error { x.GetP2PProvide = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -680,12 +670,11 @@ func (x *AnonInductive4_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil - case x.s.GetP2PProvide != nil: + case x.s.GetP2PProvide != nil: return pd1.String("GetP2PProvideRequest"), x.s.GetP2PProvide.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -706,12 +695,11 @@ func (x AnonInductive4) Kind() pd3.Kind { func (x AnonInductive4) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyRequest": + case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil - case x.GetP2PProvide != nil && key == "GetP2PProvideRequest": + case x.GetP2PProvide != nil && key == "GetP2PProvideRequest": return x.GetP2PProvide.Node(), nil - } return nil, pd1.ErrNA } @@ -733,12 +721,11 @@ func (x AnonInductive4) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive4) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyRequest": + case "IdentifyRequest": return x.Identify.Node(), nil - case "GetP2PProvideRequest": + case "GetP2PProvideRequest": return x.GetP2PProvide.Node(), nil - } return nil, pd1.ErrNA } @@ -790,14 +777,13 @@ func (x AnonInductive4) AsLink() (pd3.Link, error) { func (x AnonInductive4) Prototype() pd3.NodePrototype { return nil } + // -- protocol type AnonInductive5 -- type AnonInductive5 struct { - Identify *DelegatedRouting_IdentifyResult - GetP2PProvide *GetP2PProvideResponse - Error *DelegatedRouting_Error - - + Identify *DelegatedRouting_IdentifyResult + GetP2PProvide *GetP2PProvideResponse + Error *DelegatedRouting_Error } func (x *AnonInductive5) Parse(n pd3.Node) error { @@ -837,7 +823,6 @@ func (x *AnonInductive5) Parse(n pd3.Node) error { x.Error = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -855,14 +840,13 @@ func (x *AnonInductive5_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil - case x.s.GetP2PProvide != nil: + case x.s.GetP2PProvide != nil: return pd1.String("GetP2PProvideResponse"), x.s.GetP2PProvide.Node(), nil - case x.s.Error != nil: + case x.s.Error != nil: return pd1.String("Error"), x.s.Error.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -883,14 +867,13 @@ func (x AnonInductive5) Kind() pd3.Kind { func (x AnonInductive5) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyResponse": + case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil - case x.GetP2PProvide != nil && key == "GetP2PProvideResponse": + case x.GetP2PProvide != nil && key == "GetP2PProvideResponse": return x.GetP2PProvide.Node(), nil - case x.Error != nil && key == "Error": + case x.Error != nil && key == "Error": return x.Error.Node(), nil - } return nil, pd1.ErrNA } @@ -912,14 +895,13 @@ func (x AnonInductive5) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive5) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyResponse": + case "IdentifyResponse": return x.Identify.Node(), nil - case "GetP2PProvideResponse": + case "GetP2PProvideResponse": return x.GetP2PProvide.Node(), nil - case "Error": + case "Error": return x.Error.Node(), nil - } return nil, pd1.ErrNA } @@ -971,22 +953,19 @@ func (x AnonInductive5) AsLink() (pd3.Link, error) { func (x AnonInductive5) Prototype() pd3.NodePrototype { return nil } + var logger_client_DelegatedRouting = pd5.Logger("service/client/delegatedrouting") type DelegatedRouting_Client interface { + Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) -Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) + GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) -GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) - - -Identify_Async(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) - -GetP2PProvide_Async(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) + Identify_Async(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) + GetP2PProvide_Async(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) } - type DelegatedRouting_Identify_AsyncResult struct { Resp *DelegatedRouting_IdentifyResult Err error @@ -997,13 +976,12 @@ type DelegatedRouting_GetP2PProvide_AsyncResult struct { Err error } - type DelegatedRouting_ClientOption func(*client_DelegatedRouting) error type client_DelegatedRouting struct { - httpClient *pd4.Client - endpoint *pd12.URL - ulk pd14.Mutex + httpClient *pd4.Client + endpoint *pd12.URL + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } @@ -1028,8 +1006,6 @@ func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_Clien return c, nil } - - func (c *client_DelegatedRouting) Identify(ctx pd7.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1128,8 +1104,8 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd7.Context, ch chan<- De defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1162,14 +1138,13 @@ func process_DelegatedRouting_Identify_AsyncResult(ctx pd7.Context, ch chan<- De } select { - case <- ctx.Done(): - return - case ch <- out: + case <-ctx.Done(): + return + case ch <- out: } } } - func (c *client_DelegatedRouting) GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1268,8 +1243,8 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd7.Context, ch chan defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1302,18 +1277,16 @@ func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd7.Context, ch chan } select { - case <- ctx.Done(): - return - case ch <- out: + case <-ctx.Done(): + return + case ch <- out: } } } - var logger_server_DelegatedRouting = pd5.Logger("service/server/delegatedrouting") type DelegatedRouting_Server interface { - GetP2PProvide(ctx pd7.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) } @@ -1370,9 +1343,9 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{ Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())} } + env = &AnonInductive5{Error: &DelegatedRouting_Error{Code: pd1.String(resp.Err.Error())}} } else { - env = &AnonInductive5{ GetP2PProvide: resp.Resp } + env = &AnonInductive5{GetP2PProvide: resp.Resp} } var buf pd6.Buffer if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { @@ -1387,14 +1360,12 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { } } - case env.Identify != nil: var env *AnonInductive5 env = &AnonInductive5{ Identify: &DelegatedRouting_IdentifyResult{ Methods: []pd1.String{ "GetP2PProvide", - }, }, } @@ -1537,11 +1508,11 @@ func (iter *AnonList7_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList7_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type GetP2PProvideRequest -- type GetP2PProvideRequest struct { - Keys AnonList7 - + Keys AnonList7 } func (x GetP2PProvideRequest) Node() pd3.Node { @@ -1554,8 +1525,7 @@ func (x *GetP2PProvideRequest) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Keys": x.Keys.Parse, - + "Keys": x.Keys.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1566,14 +1536,14 @@ func (x *GetP2PProvideRequest) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Keys": - if _, notParsed := fieldMap["Keys"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Keys") - } - if err := x.Keys.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Keys") + case "Keys": + if _, notParsed := fieldMap["Keys"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Keys") + } + if err := x.Keys.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Keys") } } @@ -1595,15 +1565,15 @@ type GetP2PProvideRequest_MapIterator struct { func (x *GetP2PProvideRequest_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Keys"), x.s.Keys.Node(), nil + case 0: + return pd1.String("Keys"), x.s.Keys.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GetP2PProvideRequest_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x GetP2PProvideRequest) Kind() pd3.Kind { @@ -1612,7 +1582,7 @@ func (x GetP2PProvideRequest) Kind() pd3.Kind { func (x GetP2PProvideRequest) LookupByString(key string) (pd3.Node, error) { switch key { - case "Keys": + case "Keys": return x.Keys.Node(), nil } @@ -1639,7 +1609,7 @@ func (x GetP2PProvideRequest) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Keys.Node(), nil } @@ -1648,7 +1618,7 @@ func (x GetP2PProvideRequest) LookupByIndex(idx int64) (pd3.Node, error) { func (x GetP2PProvideRequest) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Keys": + case "0", "Keys": return x.Keys.Node(), nil } @@ -1826,11 +1796,11 @@ func (iter *AnonList9_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList9_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type GetP2PProvideResponse -- type GetP2PProvideResponse struct { - ProvidersByKey AnonList9 - + ProvidersByKey AnonList9 } func (x GetP2PProvideResponse) Node() pd3.Node { @@ -1843,8 +1813,7 @@ func (x *GetP2PProvideResponse) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "ProvidersByKey": x.ProvidersByKey.Parse, - + "ProvidersByKey": x.ProvidersByKey.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1855,14 +1824,14 @@ func (x *GetP2PProvideResponse) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "ProvidersByKey": - if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { - return pd2.Errorf("field %s already parsed", "ProvidersByKey") - } - if err := x.ProvidersByKey.Parse(vn); err != nil { - return err - } - delete(fieldMap, "ProvidersByKey") + case "ProvidersByKey": + if _, notParsed := fieldMap["ProvidersByKey"]; !notParsed { + return pd2.Errorf("field %s already parsed", "ProvidersByKey") + } + if err := x.ProvidersByKey.Parse(vn); err != nil { + return err + } + delete(fieldMap, "ProvidersByKey") } } @@ -1884,15 +1853,15 @@ type GetP2PProvideResponse_MapIterator struct { func (x *GetP2PProvideResponse_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil + case 0: + return pd1.String("ProvidersByKey"), x.s.ProvidersByKey.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GetP2PProvideResponse_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x GetP2PProvideResponse) Kind() pd3.Kind { @@ -1901,7 +1870,7 @@ func (x GetP2PProvideResponse) Kind() pd3.Kind { func (x GetP2PProvideResponse) LookupByString(key string) (pd3.Node, error) { switch key { - case "ProvidersByKey": + case "ProvidersByKey": return x.ProvidersByKey.Node(), nil } @@ -1928,7 +1897,7 @@ func (x GetP2PProvideResponse) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.ProvidersByKey.Node(), nil } @@ -1937,7 +1906,7 @@ func (x GetP2PProvideResponse) LookupByIndex(idx int64) (pd3.Node, error) { func (x GetP2PProvideResponse) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "ProvidersByKey": + case "0", "ProvidersByKey": return x.ProvidersByKey.Node(), nil } @@ -1995,9 +1964,8 @@ func (x GetP2PProvideResponse) Prototype() pd3.NodePrototype { // -- protocol type ProvidersByKey -- type ProvidersByKey struct { - Key Multihash - Provider Provider - + Key Multihash + Provider Provider } func (x ProvidersByKey) Node() pd3.Node { @@ -2010,9 +1978,8 @@ func (x *ProvidersByKey) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Key": x.Key.Parse, + "Key": x.Key.Parse, "Provider": x.Provider.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2023,22 +1990,22 @@ func (x *ProvidersByKey) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Key": - if _, notParsed := fieldMap["Key"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Key") - } - if err := x.Key.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Key") - case "Provider": - if _, notParsed := fieldMap["Provider"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Provider") - } - if err := x.Provider.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Provider") + case "Key": + if _, notParsed := fieldMap["Key"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Key") + } + if err := x.Key.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Key") + case "Provider": + if _, notParsed := fieldMap["Provider"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Provider") + } + if err := x.Provider.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Provider") } } @@ -2060,17 +2027,17 @@ type ProvidersByKey_MapIterator struct { func (x *ProvidersByKey_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Key"), x.s.Key.Node(), nil - case 1: - return pd1.String("Provider"), x.s.Provider.Node(), nil + case 0: + return pd1.String("Key"), x.s.Key.Node(), nil + case 1: + return pd1.String("Provider"), x.s.Provider.Node(), nil } return nil, nil, pd1.ErrNA } func (x *ProvidersByKey_MapIterator) Done() bool { - return x.i + 1 >= 2 + return x.i+1 >= 2 } func (x ProvidersByKey) Kind() pd3.Kind { @@ -2079,9 +2046,9 @@ func (x ProvidersByKey) Kind() pd3.Kind { func (x ProvidersByKey) LookupByString(key string) (pd3.Node, error) { switch key { - case "Key": + case "Key": return x.Key.Node(), nil - case "Provider": + case "Provider": return x.Provider.Node(), nil } @@ -2108,9 +2075,9 @@ func (x ProvidersByKey) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x ProvidersByKey) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Key.Node(), nil - case 1: + case 1: return x.Provider.Node(), nil } @@ -2119,9 +2086,9 @@ func (x ProvidersByKey) LookupByIndex(idx int64) (pd3.Node, error) { func (x ProvidersByKey) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Key": + case "0", "Key": return x.Key.Node(), nil - case "1", "Provider": + case "1", "Provider": return x.Provider.Node(), nil } @@ -2179,8 +2146,7 @@ func (x ProvidersByKey) Prototype() pd3.NodePrototype { // -- protocol type Multihash -- type Multihash struct { - Bytes pd1.Bytes - + Bytes pd1.Bytes } func (x Multihash) Node() pd3.Node { @@ -2193,8 +2159,7 @@ func (x *Multihash) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Bytes": x.Bytes.Parse, - + "Bytes": x.Bytes.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2205,14 +2170,14 @@ func (x *Multihash) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Bytes": - if _, notParsed := fieldMap["Bytes"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Bytes") - } - if err := x.Bytes.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Bytes") + case "Bytes": + if _, notParsed := fieldMap["Bytes"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Bytes") + } + if err := x.Bytes.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Bytes") } } @@ -2234,15 +2199,15 @@ type Multihash_MapIterator struct { func (x *Multihash_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Bytes"), x.s.Bytes.Node(), nil + case 0: + return pd1.String("Bytes"), x.s.Bytes.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Multihash_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x Multihash) Kind() pd3.Kind { @@ -2251,7 +2216,7 @@ func (x Multihash) Kind() pd3.Kind { func (x Multihash) LookupByString(key string) (pd3.Node, error) { switch key { - case "Bytes": + case "Bytes": return x.Bytes.Node(), nil } @@ -2278,7 +2243,7 @@ func (x Multihash) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Multihash) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Bytes.Node(), nil } @@ -2287,7 +2252,7 @@ func (x Multihash) LookupByIndex(idx int64) (pd3.Node, error) { func (x Multihash) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Bytes": + case "0", "Bytes": return x.Bytes.Node(), nil } @@ -2465,6 +2430,7 @@ func (iter *AnonList13_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList13_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type AnonList14 -- type AnonList14 []TransferProto @@ -2588,12 +2554,12 @@ func (iter *AnonList14_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList14_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type Provider -- type Provider struct { - Nodes AnonList13 - Proto AnonList14 - + Nodes AnonList13 + Proto AnonList14 } func (x Provider) Node() pd3.Node { @@ -2606,9 +2572,8 @@ func (x *Provider) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Nodes": x.Nodes.Parse, + "Nodes": x.Nodes.Parse, "Proto": x.Proto.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2619,22 +2584,22 @@ func (x *Provider) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Nodes": - if _, notParsed := fieldMap["Nodes"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Nodes") - } - if err := x.Nodes.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Nodes") - case "Proto": - if _, notParsed := fieldMap["Proto"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Proto") - } - if err := x.Proto.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Proto") + case "Nodes": + if _, notParsed := fieldMap["Nodes"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Nodes") + } + if err := x.Nodes.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Nodes") + case "Proto": + if _, notParsed := fieldMap["Proto"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Proto") + } + if err := x.Proto.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Proto") } } @@ -2656,17 +2621,17 @@ type Provider_MapIterator struct { func (x *Provider_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Nodes"), x.s.Nodes.Node(), nil - case 1: - return pd1.String("Proto"), x.s.Proto.Node(), nil + case 0: + return pd1.String("Nodes"), x.s.Nodes.Node(), nil + case 1: + return pd1.String("Proto"), x.s.Proto.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Provider_MapIterator) Done() bool { - return x.i + 1 >= 2 + return x.i+1 >= 2 } func (x Provider) Kind() pd3.Kind { @@ -2675,9 +2640,9 @@ func (x Provider) Kind() pd3.Kind { func (x Provider) LookupByString(key string) (pd3.Node, error) { switch key { - case "Nodes": + case "Nodes": return x.Nodes.Node(), nil - case "Proto": + case "Proto": return x.Proto.Node(), nil } @@ -2704,9 +2669,9 @@ func (x Provider) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Provider) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Nodes.Node(), nil - case 1: + case 1: return x.Proto.Node(), nil } @@ -2715,9 +2680,9 @@ func (x Provider) LookupByIndex(idx int64) (pd3.Node, error) { func (x Provider) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Nodes": + case "0", "Nodes": return x.Nodes.Node(), nil - case "1", "Proto": + case "1", "Proto": return x.Proto.Node(), nil } @@ -2775,9 +2740,7 @@ func (x Provider) Prototype() pd3.NodePrototype { // -- protocol type Node -- type Node struct { - Peer *Peer - - + Peer *Peer } func (x *Node) Parse(n pd3.Node) error { @@ -2803,7 +2766,6 @@ func (x *Node) Parse(n pd3.Node) error { x.Peer = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -2821,10 +2783,9 @@ func (x *Node_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { } else { x.done = true switch { - case x.s.Peer != nil: + case x.s.Peer != nil: return pd1.String("Peer"), x.s.Peer.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -2845,10 +2806,9 @@ func (x Node) Kind() pd3.Kind { func (x Node) LookupByString(key string) (pd3.Node, error) { switch { - case x.Peer != nil && key == "Peer": + case x.Peer != nil && key == "Peer": return x.Peer.Node(), nil - } return nil, pd1.ErrNA } @@ -2870,10 +2830,9 @@ func (x Node) LookupByIndex(idx int64) (pd3.Node, error) { func (x Node) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "Peer": + case "Peer": return x.Peer.Node(), nil - } return nil, pd1.ErrNA } @@ -2925,6 +2884,7 @@ func (x Node) AsLink() (pd3.Link, error) { func (x Node) Prototype() pd3.NodePrototype { return nil } + // -- protocol type AnonList17 -- type AnonList17 []pd1.Bytes @@ -3048,12 +3008,12 @@ func (iter *AnonList17_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList17_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type Peer -- type Peer struct { - ID pd1.Bytes - Multiaddresses AnonList17 - + ID pd1.Bytes + Multiaddresses AnonList17 } func (x Peer) Node() pd3.Node { @@ -3066,9 +3026,8 @@ func (x *Peer) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "ID": x.ID.Parse, + "ID": x.ID.Parse, "Multiaddresses": x.Multiaddresses.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -3079,22 +3038,22 @@ func (x *Peer) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "ID": - if _, notParsed := fieldMap["ID"]; !notParsed { - return pd2.Errorf("field %s already parsed", "ID") - } - if err := x.ID.Parse(vn); err != nil { - return err - } - delete(fieldMap, "ID") - case "Multiaddresses": - if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Multiaddresses") - } - if err := x.Multiaddresses.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Multiaddresses") + case "ID": + if _, notParsed := fieldMap["ID"]; !notParsed { + return pd2.Errorf("field %s already parsed", "ID") + } + if err := x.ID.Parse(vn); err != nil { + return err + } + delete(fieldMap, "ID") + case "Multiaddresses": + if _, notParsed := fieldMap["Multiaddresses"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Multiaddresses") + } + if err := x.Multiaddresses.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Multiaddresses") } } @@ -3116,17 +3075,17 @@ type Peer_MapIterator struct { func (x *Peer_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("ID"), x.s.ID.Node(), nil - case 1: - return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil + case 0: + return pd1.String("ID"), x.s.ID.Node(), nil + case 1: + return pd1.String("Multiaddresses"), x.s.Multiaddresses.Node(), nil } return nil, nil, pd1.ErrNA } func (x *Peer_MapIterator) Done() bool { - return x.i + 1 >= 2 + return x.i+1 >= 2 } func (x Peer) Kind() pd3.Kind { @@ -3135,9 +3094,9 @@ func (x Peer) Kind() pd3.Kind { func (x Peer) LookupByString(key string) (pd3.Node, error) { switch key { - case "ID": + case "ID": return x.ID.Node(), nil - case "Multiaddresses": + case "Multiaddresses": return x.Multiaddresses.Node(), nil } @@ -3164,9 +3123,9 @@ func (x Peer) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x Peer) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.ID.Node(), nil - case 1: + case 1: return x.Multiaddresses.Node(), nil } @@ -3175,9 +3134,9 @@ func (x Peer) LookupByIndex(idx int64) (pd3.Node, error) { func (x Peer) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "ID": + case "0", "ID": return x.ID.Node(), nil - case "1", "Multiaddresses": + case "1", "Multiaddresses": return x.Multiaddresses.Node(), nil } @@ -3235,9 +3194,7 @@ func (x Peer) Prototype() pd3.NodePrototype { // -- protocol type TransferProto -- type TransferProto struct { - Bitswap *BitswapTransfer - - + Bitswap *BitswapTransfer } func (x *TransferProto) Parse(n pd3.Node) error { @@ -3263,7 +3220,6 @@ func (x *TransferProto) Parse(n pd3.Node) error { x.Bitswap = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -3281,10 +3237,9 @@ func (x *TransferProto_MapIterator) Next() (key pd3.Node, value pd3.Node, err er } else { x.done = true switch { - case x.s.Bitswap != nil: + case x.s.Bitswap != nil: return pd1.String("Bitswap"), x.s.Bitswap.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -3305,10 +3260,9 @@ func (x TransferProto) Kind() pd3.Kind { func (x TransferProto) LookupByString(key string) (pd3.Node, error) { switch { - case x.Bitswap != nil && key == "Bitswap": + case x.Bitswap != nil && key == "Bitswap": return x.Bitswap.Node(), nil - } return nil, pd1.ErrNA } @@ -3330,10 +3284,9 @@ func (x TransferProto) LookupByIndex(idx int64) (pd3.Node, error) { func (x TransferProto) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "Bitswap": + case "Bitswap": return x.Bitswap.Node(), nil - } return nil, pd1.ErrNA } @@ -3385,10 +3338,10 @@ func (x TransferProto) AsLink() (pd3.Link, error) { func (x TransferProto) Prototype() pd3.NodePrototype { return nil } + // -- protocol type BitswapTransfer -- type BitswapTransfer struct { - } func (x BitswapTransfer) Node() pd3.Node { @@ -3400,9 +3353,7 @@ func (x *BitswapTransfer) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ - - } + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -3439,7 +3390,7 @@ func (x *BitswapTransfer_MapIterator) Next() (key pd3.Node, value pd3.Node, err } func (x *BitswapTransfer_MapIterator) Done() bool { - return x.i + 1 >= 0 + return x.i+1 >= 0 } func (x BitswapTransfer) Kind() pd3.Kind { diff --git a/examples/greeting-service/api/proto/proto_edelweiss.go b/examples/greeting-service/api/proto/proto_edelweiss.go index 4a064de..49eb1be 100644 --- a/examples/greeting-service/api/proto/proto_edelweiss.go +++ b/examples/greeting-service/api/proto/proto_edelweiss.go @@ -2,28 +2,26 @@ package proto -import( - pd1 "github.com/ipld/edelweiss/values" - pd2 "fmt" - pd3 "github.com/ipld/go-ipld-prime/datamodel" - pd4 "net/http" - pd5 "github.com/ipfs/go-log/v2" +import ( pd6 "bytes" pd7 "context" - pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" pd9 "errors" - pd10 "io" + pd2 "fmt" + pd5 "github.com/ipfs/go-log/v2" + pd13 "github.com/ipld/edelweiss/services" + pd1 "github.com/ipld/edelweiss/values" pd11 "github.com/ipld/go-ipld-prime" + pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd3 "github.com/ipld/go-ipld-prime/datamodel" + pd10 "io" + pd4 "net/http" pd12 "net/url" - pd13 "github.com/ipld/edelweiss/services" pd14 "sync" ) - // -- protocol type GreetingService_IdentifyArg -- type GreetingService_IdentifyArg struct { - } func (x GreetingService_IdentifyArg) Node() pd3.Node { @@ -35,9 +33,7 @@ func (x *GreetingService_IdentifyArg) Parse(n pd3.Node) error { return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd1.ParseFunc{ - - } + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -74,7 +70,7 @@ func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd3.Node, value pd } func (x *GreetingService_IdentifyArg_MapIterator) Done() bool { - return x.i + 1 >= 0 + return x.i+1 >= 0 } func (x GreetingService_IdentifyArg) Kind() pd3.Kind { @@ -291,11 +287,11 @@ func (iter *AnonList1_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AnonList1_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type GreetingService_IdentifyResult -- type GreetingService_IdentifyResult struct { - Methods AnonList1 - + Methods AnonList1 } func (x GreetingService_IdentifyResult) Node() pd3.Node { @@ -308,8 +304,7 @@ func (x *GreetingService_IdentifyResult) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Methods": x.Methods.Parse, - + "Methods": x.Methods.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -320,14 +315,14 @@ func (x *GreetingService_IdentifyResult) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Methods": - if _, notParsed := fieldMap["Methods"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Methods") - } - if err := x.Methods.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Methods") + case "Methods": + if _, notParsed := fieldMap["Methods"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Methods") + } + if err := x.Methods.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Methods") } } @@ -349,15 +344,15 @@ type GreetingService_IdentifyResult_MapIterator struct { func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Methods"), x.s.Methods.Node(), nil + case 0: + return pd1.String("Methods"), x.s.Methods.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GreetingService_IdentifyResult_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x GreetingService_IdentifyResult) Kind() pd3.Kind { @@ -366,7 +361,7 @@ func (x GreetingService_IdentifyResult) Kind() pd3.Kind { func (x GreetingService_IdentifyResult) LookupByString(key string) (pd3.Node, error) { switch key { - case "Methods": + case "Methods": return x.Methods.Node(), nil } @@ -393,7 +388,7 @@ func (x GreetingService_IdentifyResult) LookupByNode(key pd3.Node) (pd3.Node, er func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Methods.Node(), nil } @@ -402,7 +397,7 @@ func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd3.Node, erro func (x GreetingService_IdentifyResult) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Methods": + case "0", "Methods": return x.Methods.Node(), nil } @@ -460,8 +455,7 @@ func (x GreetingService_IdentifyResult) Prototype() pd3.NodePrototype { // -- protocol type GreetingService_Error -- type GreetingService_Error struct { - Code pd1.String - + Code pd1.String } func (x GreetingService_Error) Node() pd3.Node { @@ -474,8 +468,7 @@ func (x *GreetingService_Error) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Code": x.Code.Parse, - + "Code": x.Code.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -486,14 +479,14 @@ func (x *GreetingService_Error) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Code": - if _, notParsed := fieldMap["Code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Code") - } - if err := x.Code.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Code") + case "Code": + if _, notParsed := fieldMap["Code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Code") + } + if err := x.Code.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Code") } } @@ -515,15 +508,15 @@ type GreetingService_Error_MapIterator struct { func (x *GreetingService_Error_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Code"), x.s.Code.Node(), nil + case 0: + return pd1.String("Code"), x.s.Code.Node(), nil } return nil, nil, pd1.ErrNA } func (x *GreetingService_Error_MapIterator) Done() bool { - return x.i + 1 >= 1 + return x.i+1 >= 1 } func (x GreetingService_Error) Kind() pd3.Kind { @@ -532,7 +525,7 @@ func (x GreetingService_Error) Kind() pd3.Kind { func (x GreetingService_Error) LookupByString(key string) (pd3.Node, error) { switch key { - case "Code": + case "Code": return x.Code.Node(), nil } @@ -559,7 +552,7 @@ func (x GreetingService_Error) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x GreetingService_Error) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Code.Node(), nil } @@ -568,7 +561,7 @@ func (x GreetingService_Error) LookupByIndex(idx int64) (pd3.Node, error) { func (x GreetingService_Error) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Code": + case "0", "Code": return x.Code.Node(), nil } @@ -626,10 +619,8 @@ func (x GreetingService_Error) Prototype() pd3.NodePrototype { // -- protocol type AnonInductive4 -- type AnonInductive4 struct { - Identify *GreetingService_IdentifyArg - Hello *HelloRequest - - + Identify *GreetingService_IdentifyArg + Hello *HelloRequest } func (x *AnonInductive4) Parse(n pd3.Node) error { @@ -662,7 +653,6 @@ func (x *AnonInductive4) Parse(n pd3.Node) error { x.Hello = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -680,12 +670,11 @@ func (x *AnonInductive4_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil - case x.s.Hello != nil: + case x.s.Hello != nil: return pd1.String("HelloRequest"), x.s.Hello.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -706,12 +695,11 @@ func (x AnonInductive4) Kind() pd3.Kind { func (x AnonInductive4) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyRequest": + case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil - case x.Hello != nil && key == "HelloRequest": + case x.Hello != nil && key == "HelloRequest": return x.Hello.Node(), nil - } return nil, pd1.ErrNA } @@ -733,12 +721,11 @@ func (x AnonInductive4) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive4) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyRequest": + case "IdentifyRequest": return x.Identify.Node(), nil - case "HelloRequest": + case "HelloRequest": return x.Hello.Node(), nil - } return nil, pd1.ErrNA } @@ -790,14 +777,13 @@ func (x AnonInductive4) AsLink() (pd3.Link, error) { func (x AnonInductive4) Prototype() pd3.NodePrototype { return nil } + // -- protocol type AnonInductive5 -- type AnonInductive5 struct { - Identify *GreetingService_IdentifyResult - Hello *HelloResponse - Error *GreetingService_Error - - + Identify *GreetingService_IdentifyResult + Hello *HelloResponse + Error *GreetingService_Error } func (x *AnonInductive5) Parse(n pd3.Node) error { @@ -837,7 +823,6 @@ func (x *AnonInductive5) Parse(n pd3.Node) error { x.Error = &y return nil - } return pd2.Errorf("inductive map has no applicable keys") @@ -855,14 +840,13 @@ func (x *AnonInductive5_MapIterator) Next() (key pd3.Node, value pd3.Node, err e } else { x.done = true switch { - case x.s.Identify != nil: + case x.s.Identify != nil: return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil - case x.s.Hello != nil: + case x.s.Hello != nil: return pd1.String("HelloResponse"), x.s.Hello.Node(), nil - case x.s.Error != nil: + case x.s.Error != nil: return pd1.String("Error"), x.s.Error.Node(), nil - default: return nil, nil, pd2.Errorf("no inductive cases are set") } @@ -883,14 +867,13 @@ func (x AnonInductive5) Kind() pd3.Kind { func (x AnonInductive5) LookupByString(key string) (pd3.Node, error) { switch { - case x.Identify != nil && key == "IdentifyResponse": + case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil - case x.Hello != nil && key == "HelloResponse": + case x.Hello != nil && key == "HelloResponse": return x.Hello.Node(), nil - case x.Error != nil && key == "Error": + case x.Error != nil && key == "Error": return x.Error.Node(), nil - } return nil, pd1.ErrNA } @@ -912,14 +895,13 @@ func (x AnonInductive5) LookupByIndex(idx int64) (pd3.Node, error) { func (x AnonInductive5) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "IdentifyResponse": + case "IdentifyResponse": return x.Identify.Node(), nil - case "HelloResponse": + case "HelloResponse": return x.Hello.Node(), nil - case "Error": + case "Error": return x.Error.Node(), nil - } return nil, pd1.ErrNA } @@ -971,22 +953,19 @@ func (x AnonInductive5) AsLink() (pd3.Link, error) { func (x AnonInductive5) Prototype() pd3.NodePrototype { return nil } + var logger_client_GreetingService = pd5.Logger("service/client/greetingservice") type GreetingService_Client interface { + Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) -Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) - -Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) - + Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) -Identify_Async(ctx pd7.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) - -Hello_Async(ctx pd7.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) + Identify_Async(ctx pd7.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) + Hello_Async(ctx pd7.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) } - type GreetingService_Identify_AsyncResult struct { Resp *GreetingService_IdentifyResult Err error @@ -997,13 +976,12 @@ type GreetingService_Hello_AsyncResult struct { Err error } - type GreetingService_ClientOption func(*client_GreetingService) error type client_GreetingService struct { - httpClient *pd4.Client - endpoint *pd12.URL - ulk pd14.Mutex + httpClient *pd4.Client + endpoint *pd12.URL + ulk pd14.Mutex unsupported map[string]bool // cache of methods not supported by server } @@ -1028,8 +1006,6 @@ func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientO return c, nil } - - func (c *client_GreetingService) Identify(ctx pd7.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1128,8 +1104,8 @@ func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- Gre defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1162,14 +1138,13 @@ func process_GreetingService_Identify_AsyncResult(ctx pd7.Context, ch chan<- Gre } select { - case <- ctx.Done(): - return - case ch <- out: + case <-ctx.Done(): + return + case ch <- out: } } } - func (c *client_GreetingService) Hello(ctx pd7.Context, req *HelloRequest) ([]*HelloResponse, error) { ctx, cancel := pd7.WithCancel(ctx) defer cancel() @@ -1268,8 +1243,8 @@ func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- Greeti defer close(ch) defer r.Close() opt := pd8.DecodeOptions{ - ParseLinks: true, - ParseBytes: true, + ParseLinks: true, + ParseBytes: true, DontParseBeyondEnd: true, } for { @@ -1302,18 +1277,16 @@ func process_GreetingService_Hello_AsyncResult(ctx pd7.Context, ch chan<- Greeti } select { - case <- ctx.Done(): - return - case ch <- out: + case <-ctx.Done(): + return + case ch <- out: } } } - var logger_server_GreetingService = pd5.Logger("service/server/greetingservice") type GreetingService_Server interface { - Hello(ctx pd7.Context, req *HelloRequest) (<-chan *GreetingService_Hello_AsyncResult, error) } @@ -1370,9 +1343,9 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { } var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{ Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())} } + env = &AnonInductive5{Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())}} } else { - env = &AnonInductive5{ Hello: resp.Resp } + env = &AnonInductive5{Hello: resp.Resp} } var buf pd6.Buffer if err = pd11.EncodeStreaming(&buf, env, pd8.Encode); err != nil { @@ -1387,14 +1360,12 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { } } - case env.Identify != nil: var env *AnonInductive5 env = &AnonInductive5{ Identify: &GreetingService_IdentifyResult{ Methods: []pd1.String{ "Hello", - }, }, } @@ -1417,9 +1388,8 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd4.HandlerFunc { // -- protocol type HelloRequest -- type HelloRequest struct { - Name pd1.String - Address Address - + Name pd1.String + Address Address } func (x HelloRequest) Node() pd3.Node { @@ -1432,9 +1402,8 @@ func (x *HelloRequest) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "Name": x.Name.Parse, + "Name": x.Name.Parse, "Address": x.Address.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1445,22 +1414,22 @@ func (x *HelloRequest) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "Name": - if _, notParsed := fieldMap["Name"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Name") - } - if err := x.Name.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Name") - case "Address": - if _, notParsed := fieldMap["Address"]; !notParsed { - return pd2.Errorf("field %s already parsed", "Address") - } - if err := x.Address.Parse(vn); err != nil { - return err - } - delete(fieldMap, "Address") + case "Name": + if _, notParsed := fieldMap["Name"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Name") + } + if err := x.Name.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Name") + case "Address": + if _, notParsed := fieldMap["Address"]; !notParsed { + return pd2.Errorf("field %s already parsed", "Address") + } + if err := x.Address.Parse(vn); err != nil { + return err + } + delete(fieldMap, "Address") } } @@ -1482,17 +1451,17 @@ type HelloRequest_MapIterator struct { func (x *HelloRequest_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("Name"), x.s.Name.Node(), nil - case 1: - return pd1.String("Address"), x.s.Address.Node(), nil + case 0: + return pd1.String("Name"), x.s.Name.Node(), nil + case 1: + return pd1.String("Address"), x.s.Address.Node(), nil } return nil, nil, pd1.ErrNA } func (x *HelloRequest_MapIterator) Done() bool { - return x.i + 1 >= 2 + return x.i+1 >= 2 } func (x HelloRequest) Kind() pd3.Kind { @@ -1501,9 +1470,9 @@ func (x HelloRequest) Kind() pd3.Kind { func (x HelloRequest) LookupByString(key string) (pd3.Node, error) { switch key { - case "Name": + case "Name": return x.Name.Node(), nil - case "Address": + case "Address": return x.Address.Node(), nil } @@ -1530,9 +1499,9 @@ func (x HelloRequest) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x HelloRequest) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Name.Node(), nil - case 1: + case 1: return x.Address.Node(), nil } @@ -1541,9 +1510,9 @@ func (x HelloRequest) LookupByIndex(idx int64) (pd3.Node, error) { func (x HelloRequest) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "Name": + case "0", "Name": return x.Name.Node(), nil - case "1", "Address": + case "1", "Address": return x.Address.Node(), nil } @@ -1721,16 +1690,15 @@ func (iter *AddressLines_ListIterator) Next() (int64, pd3.Node, error) { func (iter *AddressLines_ListIterator) Done() bool { return iter.at >= iter.list.Length() } + // -- protocol type Address -- type Address struct { - US *USAddress - SK *SKAddress - - - OtherCountry string - OtherAddress *AddressLines + US *USAddress + SK *SKAddress + OtherCountry string + OtherAddress *AddressLines } func (x *Address) Parse(n pd3.Node) error { @@ -1763,7 +1731,6 @@ func (x *Address) Parse(n pd3.Node) error { x.SK = &y return nil - default: var y AddressLines if err := y.Parse(vn); err != nil { @@ -1788,14 +1755,13 @@ func (x *Address_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { } else { x.done = true switch { - case x.s.US != nil: + case x.s.US != nil: return pd1.String("US"), x.s.US.Node(), nil - case x.s.SK != nil: + case x.s.SK != nil: return pd1.String("SouthKorea"), x.s.SK.Node(), nil - - case x.s.OtherAddress != nil: - return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil + case x.s.OtherAddress != nil: + return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil default: return nil, nil, pd2.Errorf("no inductive cases are set") @@ -1817,12 +1783,11 @@ func (x Address) Kind() pd3.Kind { func (x Address) LookupByString(key string) (pd3.Node, error) { switch { - case x.US != nil && key == "US": + case x.US != nil && key == "US": return x.US.Node(), nil - case x.SK != nil && key == "SouthKorea": + case x.SK != nil && key == "SouthKorea": return x.SK.Node(), nil - case x.OtherAddress != nil && key == x.OtherCountry: return x.OtherAddress.Node(), nil @@ -1847,12 +1812,11 @@ func (x Address) LookupByIndex(idx int64) (pd3.Node, error) { func (x Address) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "US": + case "US": return x.US.Node(), nil - case "SouthKorea": + case "SouthKorea": return x.SK.Node(), nil - case x.OtherCountry: return x.OtherAddress.Node(), nil @@ -1907,14 +1871,14 @@ func (x Address) AsLink() (pd3.Link, error) { func (x Address) Prototype() pd3.NodePrototype { return nil } + // -- protocol type USAddress -- type USAddress struct { - Street pd1.String - City pd1.String - State State - ZIP pd1.Int - + Street pd1.String + City pd1.String + State State + ZIP pd1.Int } func (x USAddress) Node() pd3.Node { @@ -1927,11 +1891,10 @@ func (x *USAddress) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "street": x.Street.Parse, - "city": x.City.Parse, - "state": x.State.Parse, - "zip": x.ZIP.Parse, - + "street": x.Street.Parse, + "city": x.City.Parse, + "state": x.State.Parse, + "zip": x.ZIP.Parse, } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -1942,38 +1905,38 @@ func (x *USAddress) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "street": - if _, notParsed := fieldMap["street"]; !notParsed { - return pd2.Errorf("field %s already parsed", "street") - } - if err := x.Street.Parse(vn); err != nil { - return err - } - delete(fieldMap, "street") - case "city": - if _, notParsed := fieldMap["city"]; !notParsed { - return pd2.Errorf("field %s already parsed", "city") - } - if err := x.City.Parse(vn); err != nil { - return err - } - delete(fieldMap, "city") - case "state": - if _, notParsed := fieldMap["state"]; !notParsed { - return pd2.Errorf("field %s already parsed", "state") - } - if err := x.State.Parse(vn); err != nil { - return err - } - delete(fieldMap, "state") - case "zip": - if _, notParsed := fieldMap["zip"]; !notParsed { - return pd2.Errorf("field %s already parsed", "zip") - } - if err := x.ZIP.Parse(vn); err != nil { - return err - } - delete(fieldMap, "zip") + case "street": + if _, notParsed := fieldMap["street"]; !notParsed { + return pd2.Errorf("field %s already parsed", "street") + } + if err := x.Street.Parse(vn); err != nil { + return err + } + delete(fieldMap, "street") + case "city": + if _, notParsed := fieldMap["city"]; !notParsed { + return pd2.Errorf("field %s already parsed", "city") + } + if err := x.City.Parse(vn); err != nil { + return err + } + delete(fieldMap, "city") + case "state": + if _, notParsed := fieldMap["state"]; !notParsed { + return pd2.Errorf("field %s already parsed", "state") + } + if err := x.State.Parse(vn); err != nil { + return err + } + delete(fieldMap, "state") + case "zip": + if _, notParsed := fieldMap["zip"]; !notParsed { + return pd2.Errorf("field %s already parsed", "zip") + } + if err := x.ZIP.Parse(vn); err != nil { + return err + } + delete(fieldMap, "zip") } } @@ -1995,21 +1958,21 @@ type USAddress_MapIterator struct { func (x *USAddress_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("street"), x.s.Street.Node(), nil - case 1: - return pd1.String("city"), x.s.City.Node(), nil - case 2: - return pd1.String("state"), x.s.State.Node(), nil - case 3: - return pd1.String("zip"), x.s.ZIP.Node(), nil + case 0: + return pd1.String("street"), x.s.Street.Node(), nil + case 1: + return pd1.String("city"), x.s.City.Node(), nil + case 2: + return pd1.String("state"), x.s.State.Node(), nil + case 3: + return pd1.String("zip"), x.s.ZIP.Node(), nil } return nil, nil, pd1.ErrNA } func (x *USAddress_MapIterator) Done() bool { - return x.i + 1 >= 4 + return x.i+1 >= 4 } func (x USAddress) Kind() pd3.Kind { @@ -2018,13 +1981,13 @@ func (x USAddress) Kind() pd3.Kind { func (x USAddress) LookupByString(key string) (pd3.Node, error) { switch key { - case "street": + case "street": return x.Street.Node(), nil - case "city": + case "city": return x.City.Node(), nil - case "state": + case "state": return x.State.Node(), nil - case "zip": + case "zip": return x.ZIP.Node(), nil } @@ -2051,13 +2014,13 @@ func (x USAddress) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x USAddress) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Street.Node(), nil - case 1: + case 1: return x.City.Node(), nil - case 2: + case 2: return x.State.Node(), nil - case 3: + case 3: return x.ZIP.Node(), nil } @@ -2066,13 +2029,13 @@ func (x USAddress) LookupByIndex(idx int64) (pd3.Node, error) { func (x USAddress) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "street": + case "0", "street": return x.Street.Node(), nil - case "1", "city": + case "1", "city": return x.City.Node(), nil - case "2", "state": + case "2", "state": return x.State.Node(), nil - case "3", "zip": + case "3", "zip": return x.ZIP.Node(), nil } @@ -2310,32 +2273,31 @@ func (StateNY) Prototype() pd3.NodePrototype { // -- protocol type State -- type State struct { - CA *StateCA - NY *StateNY - Other *pd1.String - + CA *StateCA + NY *StateNY + Other *pd1.String } func (x *State) Parse(n pd3.Node) error { *x = State{} - - var CA StateCA - if err := CA.Parse(n); err == nil { - x.CA = &CA - return nil - } - - var NY StateNY - if err := NY.Parse(n); err == nil { - x.NY = &NY - return nil - } - - var Other pd1.String - if err := Other.Parse(n); err == nil { - x.Other = &Other - return nil - } + + var CA StateCA + if err := CA.Parse(n); err == nil { + x.CA = &CA + return nil + } + + var NY StateNY + if err := NY.Parse(n); err == nil { + x.NY = &NY + return nil + } + + var Other pd1.String + if err := Other.Parse(n); err == nil { + x.Other = &Other + return nil + } return pd2.Errorf("no union cases parses") } @@ -2357,129 +2319,225 @@ func (x State) Node() pd3.Node { // proxy Node methods to active case func (x State) Kind() pd3.Kind { - if x.CA != nil { return x.CA.Kind() } - if x.NY != nil { return x.NY.Kind() } - if x.Other != nil { return x.Other.Kind() } + if x.CA != nil { + return x.CA.Kind() + } + if x.NY != nil { + return x.NY.Kind() + } + if x.Other != nil { + return x.Other.Kind() + } return pd3.Kind_Invalid } func (x State) LookupByString(key string) (pd3.Node, error) { - if x.CA != nil { return x.CA.LookupByString(key) } - if x.NY != nil { return x.NY.LookupByString(key) } - if x.Other != nil { return x.Other.LookupByString(key) } + if x.CA != nil { + return x.CA.LookupByString(key) + } + if x.NY != nil { + return x.NY.LookupByString(key) + } + if x.Other != nil { + return x.Other.LookupByString(key) + } return nil, pd2.Errorf("no active union case found") } func (x State) LookupByNode(key pd3.Node) (pd3.Node, error) { - if x.CA != nil { return x.CA.LookupByNode(key) } - if x.NY != nil { return x.NY.LookupByNode(key) } - if x.Other != nil { return x.Other.LookupByNode(key) } + if x.CA != nil { + return x.CA.LookupByNode(key) + } + if x.NY != nil { + return x.NY.LookupByNode(key) + } + if x.Other != nil { + return x.Other.LookupByNode(key) + } return nil, pd2.Errorf("no active union case found") } func (x State) LookupByIndex(idx int64) (pd3.Node, error) { - if x.CA != nil { return x.CA.LookupByIndex(idx) } - if x.NY != nil { return x.NY.LookupByIndex(idx) } - if x.Other != nil { return x.Other.LookupByIndex(idx) } + if x.CA != nil { + return x.CA.LookupByIndex(idx) + } + if x.NY != nil { + return x.NY.LookupByIndex(idx) + } + if x.Other != nil { + return x.Other.LookupByIndex(idx) + } return nil, pd2.Errorf("no active union case found") } func (x State) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { - if x.CA != nil { return x.CA.LookupBySegment(seg) } - if x.NY != nil { return x.NY.LookupBySegment(seg) } - if x.Other != nil { return x.Other.LookupBySegment(seg) } + if x.CA != nil { + return x.CA.LookupBySegment(seg) + } + if x.NY != nil { + return x.NY.LookupBySegment(seg) + } + if x.Other != nil { + return x.Other.LookupBySegment(seg) + } return nil, pd2.Errorf("no active union case found") } func (x State) MapIterator() pd3.MapIterator { - if x.CA != nil { return x.CA.MapIterator() } - if x.NY != nil { return x.NY.MapIterator() } - if x.Other != nil { return x.Other.MapIterator() } + if x.CA != nil { + return x.CA.MapIterator() + } + if x.NY != nil { + return x.NY.MapIterator() + } + if x.Other != nil { + return x.Other.MapIterator() + } return nil } func (x State) ListIterator() pd3.ListIterator { - if x.CA != nil { return x.CA.ListIterator() } - if x.NY != nil { return x.NY.ListIterator() } - if x.Other != nil { return x.Other.ListIterator() } + if x.CA != nil { + return x.CA.ListIterator() + } + if x.NY != nil { + return x.NY.ListIterator() + } + if x.Other != nil { + return x.Other.ListIterator() + } return nil } func (x State) Length() int64 { - if x.CA != nil { return x.CA.Length() } - if x.NY != nil { return x.NY.Length() } - if x.Other != nil { return x.Other.Length() } + if x.CA != nil { + return x.CA.Length() + } + if x.NY != nil { + return x.NY.Length() + } + if x.Other != nil { + return x.Other.Length() + } return -1 } func (x State) IsAbsent() bool { - if x.CA != nil { return x.CA.IsAbsent() } - if x.NY != nil { return x.NY.IsAbsent() } - if x.Other != nil { return x.Other.IsAbsent() } + if x.CA != nil { + return x.CA.IsAbsent() + } + if x.NY != nil { + return x.NY.IsAbsent() + } + if x.Other != nil { + return x.Other.IsAbsent() + } return false } func (x State) IsNull() bool { - if x.CA != nil { return x.CA.IsNull() } - if x.NY != nil { return x.NY.IsNull() } - if x.Other != nil { return x.Other.IsNull() } + if x.CA != nil { + return x.CA.IsNull() + } + if x.NY != nil { + return x.NY.IsNull() + } + if x.Other != nil { + return x.Other.IsNull() + } return false } func (x State) AsBool() (bool, error) { - if x.CA != nil { return x.CA.AsBool() } - if x.NY != nil { return x.NY.AsBool() } - if x.Other != nil { return x.Other.AsBool() } + if x.CA != nil { + return x.CA.AsBool() + } + if x.NY != nil { + return x.NY.AsBool() + } + if x.Other != nil { + return x.Other.AsBool() + } return false, pd2.Errorf("no active union case found") } func (x State) AsInt() (int64, error) { - if x.CA != nil { return x.CA.AsInt() } - if x.NY != nil { return x.NY.AsInt() } - if x.Other != nil { return x.Other.AsInt() } + if x.CA != nil { + return x.CA.AsInt() + } + if x.NY != nil { + return x.NY.AsInt() + } + if x.Other != nil { + return x.Other.AsInt() + } return 0, pd2.Errorf("no active union case found") } func (x State) AsFloat() (float64, error) { - if x.CA != nil { return x.CA.AsFloat() } - if x.NY != nil { return x.NY.AsFloat() } - if x.Other != nil { return x.Other.AsFloat() } + if x.CA != nil { + return x.CA.AsFloat() + } + if x.NY != nil { + return x.NY.AsFloat() + } + if x.Other != nil { + return x.Other.AsFloat() + } return 0.0, pd2.Errorf("no active union case found") } func (x State) AsString() (string, error) { - if x.CA != nil { return x.CA.AsString() } - if x.NY != nil { return x.NY.AsString() } - if x.Other != nil { return x.Other.AsString() } + if x.CA != nil { + return x.CA.AsString() + } + if x.NY != nil { + return x.NY.AsString() + } + if x.Other != nil { + return x.Other.AsString() + } return "", pd2.Errorf("no active union case found") } func (x State) AsBytes() ([]byte, error) { - if x.CA != nil { return x.CA.AsBytes() } - if x.NY != nil { return x.NY.AsBytes() } - if x.Other != nil { return x.Other.AsBytes() } + if x.CA != nil { + return x.CA.AsBytes() + } + if x.NY != nil { + return x.NY.AsBytes() + } + if x.Other != nil { + return x.Other.AsBytes() + } return nil, pd2.Errorf("no active union case found") } func (x State) AsLink() (pd3.Link, error) { - if x.CA != nil { return x.CA.AsLink() } - if x.NY != nil { return x.NY.AsLink() } - if x.Other != nil { return x.Other.AsLink() } + if x.CA != nil { + return x.CA.AsLink() + } + if x.NY != nil { + return x.NY.AsLink() + } + if x.Other != nil { + return x.Other.AsLink() + } return nil, pd2.Errorf("no active union case found") } @@ -2487,14 +2545,14 @@ func (x State) AsLink() (pd3.Link, error) { func (x State) Prototype() pd3.NodePrototype { return nil } + // -- protocol type SKAddress -- type SKAddress struct { - Street pd1.String - City pd1.String - Province pd1.String - PostalCode pd1.Int - + Street pd1.String + City pd1.String + Province pd1.String + PostalCode pd1.Int } func (x SKAddress) Node() pd3.Node { @@ -2507,11 +2565,10 @@ func (x *SKAddress) Parse(n pd3.Node) error { } iter := n.MapIterator() fieldMap := map[string]pd1.ParseFunc{ - "street": x.Street.Parse, - "city": x.City.Parse, - "province": x.Province.Parse, + "street": x.Street.Parse, + "city": x.City.Parse, + "province": x.Province.Parse, "postal_code": x.PostalCode.Parse, - } for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { @@ -2522,38 +2579,38 @@ func (x *SKAddress) Parse(n pd3.Node) error { } else { _ = vn switch k { - case "street": - if _, notParsed := fieldMap["street"]; !notParsed { - return pd2.Errorf("field %s already parsed", "street") - } - if err := x.Street.Parse(vn); err != nil { - return err - } - delete(fieldMap, "street") - case "city": - if _, notParsed := fieldMap["city"]; !notParsed { - return pd2.Errorf("field %s already parsed", "city") - } - if err := x.City.Parse(vn); err != nil { - return err - } - delete(fieldMap, "city") - case "province": - if _, notParsed := fieldMap["province"]; !notParsed { - return pd2.Errorf("field %s already parsed", "province") - } - if err := x.Province.Parse(vn); err != nil { - return err - } - delete(fieldMap, "province") - case "postal_code": - if _, notParsed := fieldMap["postal_code"]; !notParsed { - return pd2.Errorf("field %s already parsed", "postal_code") - } - if err := x.PostalCode.Parse(vn); err != nil { - return err - } - delete(fieldMap, "postal_code") + case "street": + if _, notParsed := fieldMap["street"]; !notParsed { + return pd2.Errorf("field %s already parsed", "street") + } + if err := x.Street.Parse(vn); err != nil { + return err + } + delete(fieldMap, "street") + case "city": + if _, notParsed := fieldMap["city"]; !notParsed { + return pd2.Errorf("field %s already parsed", "city") + } + if err := x.City.Parse(vn); err != nil { + return err + } + delete(fieldMap, "city") + case "province": + if _, notParsed := fieldMap["province"]; !notParsed { + return pd2.Errorf("field %s already parsed", "province") + } + if err := x.Province.Parse(vn); err != nil { + return err + } + delete(fieldMap, "province") + case "postal_code": + if _, notParsed := fieldMap["postal_code"]; !notParsed { + return pd2.Errorf("field %s already parsed", "postal_code") + } + if err := x.PostalCode.Parse(vn); err != nil { + return err + } + delete(fieldMap, "postal_code") } } @@ -2575,21 +2632,21 @@ type SKAddress_MapIterator struct { func (x *SKAddress_MapIterator) Next() (key pd3.Node, value pd3.Node, err error) { x.i++ switch x.i { - case 0: - return pd1.String("street"), x.s.Street.Node(), nil - case 1: - return pd1.String("city"), x.s.City.Node(), nil - case 2: - return pd1.String("province"), x.s.Province.Node(), nil - case 3: - return pd1.String("postal_code"), x.s.PostalCode.Node(), nil + case 0: + return pd1.String("street"), x.s.Street.Node(), nil + case 1: + return pd1.String("city"), x.s.City.Node(), nil + case 2: + return pd1.String("province"), x.s.Province.Node(), nil + case 3: + return pd1.String("postal_code"), x.s.PostalCode.Node(), nil } return nil, nil, pd1.ErrNA } func (x *SKAddress_MapIterator) Done() bool { - return x.i + 1 >= 4 + return x.i+1 >= 4 } func (x SKAddress) Kind() pd3.Kind { @@ -2598,13 +2655,13 @@ func (x SKAddress) Kind() pd3.Kind { func (x SKAddress) LookupByString(key string) (pd3.Node, error) { switch key { - case "street": + case "street": return x.Street.Node(), nil - case "city": + case "city": return x.City.Node(), nil - case "province": + case "province": return x.Province.Node(), nil - case "postal_code": + case "postal_code": return x.PostalCode.Node(), nil } @@ -2631,13 +2688,13 @@ func (x SKAddress) LookupByNode(key pd3.Node) (pd3.Node, error) { func (x SKAddress) LookupByIndex(idx int64) (pd3.Node, error) { switch idx { - case 0: + case 0: return x.Street.Node(), nil - case 1: + case 1: return x.City.Node(), nil - case 2: + case 2: return x.Province.Node(), nil - case 3: + case 3: return x.PostalCode.Node(), nil } @@ -2646,13 +2703,13 @@ func (x SKAddress) LookupByIndex(idx int64) (pd3.Node, error) { func (x SKAddress) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { switch seg.String() { - case "0", "street": + case "0", "street": return x.Street.Node(), nil - case "1", "city": + case "1", "city": return x.City.Node(), nil - case "2", "province": + case "2", "province": return x.Province.Node(), nil - case "3", "postal_code": + case "3", "postal_code": return x.PostalCode.Node(), nil } @@ -2710,25 +2767,24 @@ func (x SKAddress) Prototype() pd3.NodePrototype { // -- protocol type HelloResponse -- type HelloResponse struct { - English *pd1.String - Korean *pd1.String - + English *pd1.String + Korean *pd1.String } func (x *HelloResponse) Parse(n pd3.Node) error { *x = HelloResponse{} - - var English pd1.String - if err := English.Parse(n); err == nil { - x.English = &English - return nil - } - - var Korean pd1.String - if err := Korean.Parse(n); err == nil { - x.Korean = &Korean - return nil - } + + var English pd1.String + if err := English.Parse(n); err == nil { + x.English = &English + return nil + } + + var Korean pd1.String + if err := Korean.Parse(n); err == nil { + x.Korean = &Korean + return nil + } return pd2.Errorf("no union cases parses") } @@ -2747,117 +2803,181 @@ func (x HelloResponse) Node() pd3.Node { // proxy Node methods to active case func (x HelloResponse) Kind() pd3.Kind { - if x.English != nil { return x.English.Kind() } - if x.Korean != nil { return x.Korean.Kind() } + if x.English != nil { + return x.English.Kind() + } + if x.Korean != nil { + return x.Korean.Kind() + } return pd3.Kind_Invalid } func (x HelloResponse) LookupByString(key string) (pd3.Node, error) { - if x.English != nil { return x.English.LookupByString(key) } - if x.Korean != nil { return x.Korean.LookupByString(key) } + if x.English != nil { + return x.English.LookupByString(key) + } + if x.Korean != nil { + return x.Korean.LookupByString(key) + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupByNode(key pd3.Node) (pd3.Node, error) { - if x.English != nil { return x.English.LookupByNode(key) } - if x.Korean != nil { return x.Korean.LookupByNode(key) } + if x.English != nil { + return x.English.LookupByNode(key) + } + if x.Korean != nil { + return x.Korean.LookupByNode(key) + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupByIndex(idx int64) (pd3.Node, error) { - if x.English != nil { return x.English.LookupByIndex(idx) } - if x.Korean != nil { return x.Korean.LookupByIndex(idx) } + if x.English != nil { + return x.English.LookupByIndex(idx) + } + if x.Korean != nil { + return x.Korean.LookupByIndex(idx) + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) LookupBySegment(seg pd3.PathSegment) (pd3.Node, error) { - if x.English != nil { return x.English.LookupBySegment(seg) } - if x.Korean != nil { return x.Korean.LookupBySegment(seg) } + if x.English != nil { + return x.English.LookupBySegment(seg) + } + if x.Korean != nil { + return x.Korean.LookupBySegment(seg) + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) MapIterator() pd3.MapIterator { - if x.English != nil { return x.English.MapIterator() } - if x.Korean != nil { return x.Korean.MapIterator() } + if x.English != nil { + return x.English.MapIterator() + } + if x.Korean != nil { + return x.Korean.MapIterator() + } return nil } func (x HelloResponse) ListIterator() pd3.ListIterator { - if x.English != nil { return x.English.ListIterator() } - if x.Korean != nil { return x.Korean.ListIterator() } + if x.English != nil { + return x.English.ListIterator() + } + if x.Korean != nil { + return x.Korean.ListIterator() + } return nil } func (x HelloResponse) Length() int64 { - if x.English != nil { return x.English.Length() } - if x.Korean != nil { return x.Korean.Length() } + if x.English != nil { + return x.English.Length() + } + if x.Korean != nil { + return x.Korean.Length() + } return -1 } func (x HelloResponse) IsAbsent() bool { - if x.English != nil { return x.English.IsAbsent() } - if x.Korean != nil { return x.Korean.IsAbsent() } + if x.English != nil { + return x.English.IsAbsent() + } + if x.Korean != nil { + return x.Korean.IsAbsent() + } return false } func (x HelloResponse) IsNull() bool { - if x.English != nil { return x.English.IsNull() } - if x.Korean != nil { return x.Korean.IsNull() } + if x.English != nil { + return x.English.IsNull() + } + if x.Korean != nil { + return x.Korean.IsNull() + } return false } func (x HelloResponse) AsBool() (bool, error) { - if x.English != nil { return x.English.AsBool() } - if x.Korean != nil { return x.Korean.AsBool() } + if x.English != nil { + return x.English.AsBool() + } + if x.Korean != nil { + return x.Korean.AsBool() + } return false, pd2.Errorf("no active union case found") } func (x HelloResponse) AsInt() (int64, error) { - if x.English != nil { return x.English.AsInt() } - if x.Korean != nil { return x.Korean.AsInt() } + if x.English != nil { + return x.English.AsInt() + } + if x.Korean != nil { + return x.Korean.AsInt() + } return 0, pd2.Errorf("no active union case found") } func (x HelloResponse) AsFloat() (float64, error) { - if x.English != nil { return x.English.AsFloat() } - if x.Korean != nil { return x.Korean.AsFloat() } + if x.English != nil { + return x.English.AsFloat() + } + if x.Korean != nil { + return x.Korean.AsFloat() + } return 0.0, pd2.Errorf("no active union case found") } func (x HelloResponse) AsString() (string, error) { - if x.English != nil { return x.English.AsString() } - if x.Korean != nil { return x.Korean.AsString() } + if x.English != nil { + return x.English.AsString() + } + if x.Korean != nil { + return x.Korean.AsString() + } return "", pd2.Errorf("no active union case found") } func (x HelloResponse) AsBytes() ([]byte, error) { - if x.English != nil { return x.English.AsBytes() } - if x.Korean != nil { return x.Korean.AsBytes() } + if x.English != nil { + return x.English.AsBytes() + } + if x.Korean != nil { + return x.Korean.AsBytes() + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) AsLink() (pd3.Link, error) { - if x.English != nil { return x.English.AsLink() } - if x.Korean != nil { return x.Korean.AsLink() } + if x.English != nil { + return x.English.AsLink() + } + if x.Korean != nil { + return x.Korean.AsLink() + } return nil, pd2.Errorf("no active union case found") } func (x HelloResponse) Prototype() pd3.NodePrototype { return nil -} \ No newline at end of file +}