// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. package shlf 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 *ActorProfile) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) if _, err := cw.Write([]byte{163}); 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("space.shlf.actor.profile"))); err != nil { return err } if _, err := cw.WriteString(string("space.shlf.actor.profile")); err != nil { return err } // t.CreatedAt (string) (string) if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { return err } if _, err := cw.WriteString(string("createdAt")); err != nil { return err } if len(t.CreatedAt) > 1000000 { return xerrors.Errorf("Value in field t.CreatedAt was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { return err } if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { return err } // t.DisplayName (string) (string) if len("displayName") > 1000000 { return xerrors.Errorf("Value in field \"displayName\" was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("displayName"))); err != nil { return err } if _, err := cw.WriteString(string("displayName")); err != nil { return err } if len(t.DisplayName) > 1000000 { return xerrors.Errorf("Value in field t.DisplayName was too long") } if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.DisplayName))); err != nil { return err } if _, err := cw.WriteString(string(t.DisplayName)); err != nil { return err } return nil } func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { *t = ActorProfile{} 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("ActorProfile: map struct too large (%d)", extra) } n := extra nameBuf := make([]byte, 11) 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.LexiconTypeID (string) (string) case "$type": { sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.LexiconTypeID = string(sval) } // t.CreatedAt (string) (string) case "createdAt": { sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.CreatedAt = string(sval) } // t.DisplayName (string) (string) case "displayName": { sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } t.DisplayName = 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 }