// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. package bild import ( "fmt" "io" "math" "sort" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" ) var _ = xerrors.Errorf var _ = cid.Undef var _ = math.E var _ = sort.Sort func (t *PublicKey) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) if _, err := cw.Write([]byte{164}); err != nil { return err } // t.Key (string) (string) if len("key") > 1000000 { return xerrors.Errorf("Value in field \"key\" was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil { return err } if _, err := cw.WriteString(string("key")); err != nil { return err } if len(t.Key) > 1000000 { return xerrors.Errorf("Value in field t.Key was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil { return err } if _, err := cw.WriteString(string(t.Key)); err != nil { return err } // t.Name (string) (string) if len("name") > 1000000 { return xerrors.Errorf("Value in field \"name\" was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil { return err } if _, err := cw.WriteString(string("name")); err != nil { return err } if len(t.Name) > 1000000 { return xerrors.Errorf("Value in field t.Name was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil { return err } if _, err := cw.WriteString(string(t.Name)); err != nil { return err } // t.LexiconTypeID (string) (string) if len("$type") > 1000000 { return xerrors.Errorf("Value in field \"$type\" was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { return err } if _, err := cw.WriteString(string("$type")); err != nil { return err } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.bild.publicKey"))); err != nil { return err } if _, err := cw.WriteString(string("sh.bild.publicKey")); err != nil { return err } // t.Created (string) (string) if len("created") > 1000000 { return xerrors.Errorf("Value in field \"created\" was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("created"))); err != nil { return err } if _, err := cw.WriteString(string("created")); err != nil { return err } if len(t.Created) > 1000000 { return xerrors.Errorf("Value in field t.Created was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Created))); err != nil { return err } if _, err := cw.WriteString(string(t.Created)); err != nil { return err } return nil } func (t *PublicKey) UnmarshalCBOR(r io.Reader) (err error) { *t = PublicKey{} cr := cbg.NewCborReader(r) maj, extra, err := cr.ReadHeader() if err != nil { return err } defer func() { if err == io.EOF { err = io.ErrUnexpectedEOF } }() if maj != cbg.MajMap { return fmt.Errorf("cbor input should be of type map") } if extra > cbg.MaxLength { return fmt.Errorf("PublicKey: map struct too large (%d)", extra) } n := extra nameBuf := make([]byte, 7) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { return err } if !ok { // Field doesn't exist on this type, so ignore it if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { return err } continue } switch string(nameBuf[:nameLen]) { // t.Key (string) (string) case "key": { sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.Key = string(sval) } // t.Name (string) (string) case "name": { sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.Name = string(sval) } // t.LexiconTypeID (string) (string) case "$type": { sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.LexiconTypeID = string(sval) } // t.Created (string) (string) case "created": { sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.Created = string(sval) } default: // Field doesn't exist on this type, so ignore it if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { return err } } } return nil }