···
+
func (t *Comment) MarshalCBOR(w io.Writer) error {
+
_, err := w.Write(cbg.CborNull)
+
cw := cbg.NewCborWriter(w)
+
if t.References == nil {
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
+
// t.Body (string) (string)
+
if len("body") > 1000000 {
+
return xerrors.Errorf("Value in field \"body\" was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
+
if _, err := cw.WriteString(string("body")); err != nil {
+
if len(t.Body) > 1000000 {
+
return xerrors.Errorf("Value in field t.Body was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil {
+
if _, err := cw.WriteString(string(t.Body)); err != nil {
+
// 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 {
+
if _, err := cw.WriteString(string("$type")); err != nil {
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.comment"))); err != nil {
+
if _, err := cw.WriteString(string("sh.tangled.comment")); err != nil {
+
// t.ReplyTo (string) (string)
+
if len("replyTo") > 1000000 {
+
return xerrors.Errorf("Value in field \"replyTo\" was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("replyTo"))); err != nil {
+
if _, err := cw.WriteString(string("replyTo")); err != nil {
+
if _, err := cw.Write(cbg.CborNull); err != nil {
+
if len(*t.ReplyTo) > 1000000 {
+
return xerrors.Errorf("Value in field t.ReplyTo was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ReplyTo))); err != nil {
+
if _, err := cw.WriteString(string(*t.ReplyTo)); err != nil {
+
// t.Subject (string) (string)
+
if len("subject") > 1000000 {
+
return xerrors.Errorf("Value in field \"subject\" was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil {
+
if _, err := cw.WriteString(string("subject")); err != nil {
+
if len(t.Subject) > 1000000 {
+
return xerrors.Errorf("Value in field t.Subject was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil {
+
if _, err := cw.WriteString(string(t.Subject)); err != nil {
+
// t.Mentions ([]string) (slice)
+
if len("mentions") > 1000000 {
+
return xerrors.Errorf("Value in field \"mentions\" was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil {
+
if _, err := cw.WriteString(string("mentions")); err != nil {
+
if len(t.Mentions) > 8192 {
+
return xerrors.Errorf("Slice value in field t.Mentions was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil {
+
for _, v := range t.Mentions {
+
return xerrors.Errorf("Value in field v was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
+
if _, err := cw.WriteString(string(v)); err != nil {
+
// 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 {
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
+
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 {
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
+
// t.References ([]string) (slice)
+
if t.References != nil {
+
if len("references") > 1000000 {
+
return xerrors.Errorf("Value in field \"references\" was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil {
+
if _, err := cw.WriteString(string("references")); err != nil {
+
if len(t.References) > 8192 {
+
return xerrors.Errorf("Slice value in field t.References was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil {
+
for _, v := range t.References {
+
return xerrors.Errorf("Value in field v was too long")
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
+
if _, err := cw.WriteString(string(v)); err != nil {
+
func (t *Comment) UnmarshalCBOR(r io.Reader) (err error) {
+
cr := cbg.NewCborReader(r)
+
maj, extra, err := cr.ReadHeader()
+
err = io.ErrUnexpectedEOF
+
return fmt.Errorf("cbor input should be of type map")
+
if extra > cbg.MaxLength {
+
return fmt.Errorf("Comment: map struct too large (%d)", extra)
+
nameBuf := make([]byte, 10)
+
for i := uint64(0); i < n; i++ {
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
+
// Field doesn't exist on this type, so ignore it
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
+
switch string(nameBuf[:nameLen]) {
+
// t.Body (string) (string)
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
// t.LexiconTypeID (string) (string)
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
t.LexiconTypeID = string(sval)
+
// t.ReplyTo (string) (string)
+
b, err := cr.ReadByte()
+
if b != cbg.CborNull[0] {
+
if err := cr.UnreadByte(); err != nil {
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
t.ReplyTo = (*string)(&sval)
+
// t.Subject (string) (string)
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
t.Subject = string(sval)
+
// t.Mentions ([]string) (slice)
+
maj, extra, err = cr.ReadHeader()
+
return fmt.Errorf("t.Mentions: array too large (%d)", extra)
+
if maj != cbg.MajArray {
+
return fmt.Errorf("expected cbor array")
+
t.Mentions = make([]string, extra)
+
for i := 0; i < int(extra); i++ {
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
t.Mentions[i] = string(sval)
+
// t.CreatedAt (string) (string)
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
t.CreatedAt = string(sval)
+
// t.References ([]string) (slice)
+
maj, extra, err = cr.ReadHeader()
+
return fmt.Errorf("t.References: array too large (%d)", extra)
+
if maj != cbg.MajArray {
+
return fmt.Errorf("expected cbor array")
+
t.References = make([]string, extra)
+
for i := 0; i < int(extra); i++ {
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
t.References[i] = string(sval)
+
// Field doesn't exist on this type, so ignore it
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
func (t *FeedReaction) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull)