// Code generated by gotdgen, DO NOT EDIT. package tdapi import ( "context" "errors" "fmt" "sort" "strings" "go.uber.org/multierr" "go.mau.fi/mautrix-telegram/pkg/gotd/bin" "go.mau.fi/mautrix-telegram/pkg/gotd/tdjson" "go.mau.fi/mautrix-telegram/pkg/gotd/tdp" "go.mau.fi/mautrix-telegram/pkg/gotd/tgerr" ) // No-op definition for keeping imports. var ( _ = bin.Buffer{} _ = context.Background() _ = fmt.Stringer(nil) _ = strings.Builder{} _ = errors.Is _ = multierr.AppendInto _ = sort.Ints _ = tdp.Format _ = tgerr.Error{} _ = tdjson.Encoder{} ) // MessageReadDateRead represents TL type `messageReadDateRead#758d2e30`. type MessageReadDateRead struct { // Point in time (Unix timestamp) when the message was read by the other user ReadDate int32 } // MessageReadDateReadTypeID is TL type id of MessageReadDateRead. const MessageReadDateReadTypeID = 0x758d2e30 // construct implements constructor of MessageReadDateClass. func (m MessageReadDateRead) construct() MessageReadDateClass { return &m } // Ensuring interfaces in compile-time for MessageReadDateRead. var ( _ bin.Encoder = &MessageReadDateRead{} _ bin.Decoder = &MessageReadDateRead{} _ bin.BareEncoder = &MessageReadDateRead{} _ bin.BareDecoder = &MessageReadDateRead{} _ MessageReadDateClass = &MessageReadDateRead{} ) func (m *MessageReadDateRead) Zero() bool { if m == nil { return true } if !(m.ReadDate == 0) { return false } return true } // String implements fmt.Stringer. func (m *MessageReadDateRead) String() string { if m == nil { return "MessageReadDateRead(nil)" } type Alias MessageReadDateRead return fmt.Sprintf("MessageReadDateRead%+v", Alias(*m)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*MessageReadDateRead) TypeID() uint32 { return MessageReadDateReadTypeID } // TypeName returns name of type in TL schema. func (*MessageReadDateRead) TypeName() string { return "messageReadDateRead" } // TypeInfo returns info about TL type. func (m *MessageReadDateRead) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "messageReadDateRead", ID: MessageReadDateReadTypeID, } if m == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ReadDate", SchemaName: "read_date", }, } return typ } // Encode implements bin.Encoder. func (m *MessageReadDateRead) Encode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateRead#758d2e30 as nil") } b.PutID(MessageReadDateReadTypeID) return m.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (m *MessageReadDateRead) EncodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateRead#758d2e30 as nil") } b.PutInt32(m.ReadDate) return nil } // Decode implements bin.Decoder. func (m *MessageReadDateRead) Decode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateRead#758d2e30 to nil") } if err := b.ConsumeID(MessageReadDateReadTypeID); err != nil { return fmt.Errorf("unable to decode messageReadDateRead#758d2e30: %w", err) } return m.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (m *MessageReadDateRead) DecodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateRead#758d2e30 to nil") } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode messageReadDateRead#758d2e30: field read_date: %w", err) } m.ReadDate = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (m *MessageReadDateRead) EncodeTDLibJSON(b tdjson.Encoder) error { if m == nil { return fmt.Errorf("can't encode messageReadDateRead#758d2e30 as nil") } b.ObjStart() b.PutID("messageReadDateRead") b.Comma() b.FieldStart("read_date") b.PutInt32(m.ReadDate) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (m *MessageReadDateRead) DecodeTDLibJSON(b tdjson.Decoder) error { if m == nil { return fmt.Errorf("can't decode messageReadDateRead#758d2e30 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("messageReadDateRead"); err != nil { return fmt.Errorf("unable to decode messageReadDateRead#758d2e30: %w", err) } case "read_date": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode messageReadDateRead#758d2e30: field read_date: %w", err) } m.ReadDate = value default: return b.Skip() } return nil }) } // GetReadDate returns value of ReadDate field. func (m *MessageReadDateRead) GetReadDate() (value int32) { if m == nil { return } return m.ReadDate } // MessageReadDateUnread represents TL type `messageReadDateUnread#17b2212c`. type MessageReadDateUnread struct { } // MessageReadDateUnreadTypeID is TL type id of MessageReadDateUnread. const MessageReadDateUnreadTypeID = 0x17b2212c // construct implements constructor of MessageReadDateClass. func (m MessageReadDateUnread) construct() MessageReadDateClass { return &m } // Ensuring interfaces in compile-time for MessageReadDateUnread. var ( _ bin.Encoder = &MessageReadDateUnread{} _ bin.Decoder = &MessageReadDateUnread{} _ bin.BareEncoder = &MessageReadDateUnread{} _ bin.BareDecoder = &MessageReadDateUnread{} _ MessageReadDateClass = &MessageReadDateUnread{} ) func (m *MessageReadDateUnread) Zero() bool { if m == nil { return true } return true } // String implements fmt.Stringer. func (m *MessageReadDateUnread) String() string { if m == nil { return "MessageReadDateUnread(nil)" } type Alias MessageReadDateUnread return fmt.Sprintf("MessageReadDateUnread%+v", Alias(*m)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*MessageReadDateUnread) TypeID() uint32 { return MessageReadDateUnreadTypeID } // TypeName returns name of type in TL schema. func (*MessageReadDateUnread) TypeName() string { return "messageReadDateUnread" } // TypeInfo returns info about TL type. func (m *MessageReadDateUnread) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "messageReadDateUnread", ID: MessageReadDateUnreadTypeID, } if m == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (m *MessageReadDateUnread) Encode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateUnread#17b2212c as nil") } b.PutID(MessageReadDateUnreadTypeID) return m.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (m *MessageReadDateUnread) EncodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateUnread#17b2212c as nil") } return nil } // Decode implements bin.Decoder. func (m *MessageReadDateUnread) Decode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateUnread#17b2212c to nil") } if err := b.ConsumeID(MessageReadDateUnreadTypeID); err != nil { return fmt.Errorf("unable to decode messageReadDateUnread#17b2212c: %w", err) } return m.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (m *MessageReadDateUnread) DecodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateUnread#17b2212c to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (m *MessageReadDateUnread) EncodeTDLibJSON(b tdjson.Encoder) error { if m == nil { return fmt.Errorf("can't encode messageReadDateUnread#17b2212c as nil") } b.ObjStart() b.PutID("messageReadDateUnread") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (m *MessageReadDateUnread) DecodeTDLibJSON(b tdjson.Decoder) error { if m == nil { return fmt.Errorf("can't decode messageReadDateUnread#17b2212c to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("messageReadDateUnread"); err != nil { return fmt.Errorf("unable to decode messageReadDateUnread#17b2212c: %w", err) } default: return b.Skip() } return nil }) } // MessageReadDateTooOld represents TL type `messageReadDateTooOld#b6761e20`. type MessageReadDateTooOld struct { } // MessageReadDateTooOldTypeID is TL type id of MessageReadDateTooOld. const MessageReadDateTooOldTypeID = 0xb6761e20 // construct implements constructor of MessageReadDateClass. func (m MessageReadDateTooOld) construct() MessageReadDateClass { return &m } // Ensuring interfaces in compile-time for MessageReadDateTooOld. var ( _ bin.Encoder = &MessageReadDateTooOld{} _ bin.Decoder = &MessageReadDateTooOld{} _ bin.BareEncoder = &MessageReadDateTooOld{} _ bin.BareDecoder = &MessageReadDateTooOld{} _ MessageReadDateClass = &MessageReadDateTooOld{} ) func (m *MessageReadDateTooOld) Zero() bool { if m == nil { return true } return true } // String implements fmt.Stringer. func (m *MessageReadDateTooOld) String() string { if m == nil { return "MessageReadDateTooOld(nil)" } type Alias MessageReadDateTooOld return fmt.Sprintf("MessageReadDateTooOld%+v", Alias(*m)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*MessageReadDateTooOld) TypeID() uint32 { return MessageReadDateTooOldTypeID } // TypeName returns name of type in TL schema. func (*MessageReadDateTooOld) TypeName() string { return "messageReadDateTooOld" } // TypeInfo returns info about TL type. func (m *MessageReadDateTooOld) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "messageReadDateTooOld", ID: MessageReadDateTooOldTypeID, } if m == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (m *MessageReadDateTooOld) Encode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateTooOld#b6761e20 as nil") } b.PutID(MessageReadDateTooOldTypeID) return m.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (m *MessageReadDateTooOld) EncodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateTooOld#b6761e20 as nil") } return nil } // Decode implements bin.Decoder. func (m *MessageReadDateTooOld) Decode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateTooOld#b6761e20 to nil") } if err := b.ConsumeID(MessageReadDateTooOldTypeID); err != nil { return fmt.Errorf("unable to decode messageReadDateTooOld#b6761e20: %w", err) } return m.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (m *MessageReadDateTooOld) DecodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateTooOld#b6761e20 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (m *MessageReadDateTooOld) EncodeTDLibJSON(b tdjson.Encoder) error { if m == nil { return fmt.Errorf("can't encode messageReadDateTooOld#b6761e20 as nil") } b.ObjStart() b.PutID("messageReadDateTooOld") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (m *MessageReadDateTooOld) DecodeTDLibJSON(b tdjson.Decoder) error { if m == nil { return fmt.Errorf("can't decode messageReadDateTooOld#b6761e20 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("messageReadDateTooOld"); err != nil { return fmt.Errorf("unable to decode messageReadDateTooOld#b6761e20: %w", err) } default: return b.Skip() } return nil }) } // MessageReadDateUserPrivacyRestricted represents TL type `messageReadDateUserPrivacyRestricted#b38d9426`. type MessageReadDateUserPrivacyRestricted struct { } // MessageReadDateUserPrivacyRestrictedTypeID is TL type id of MessageReadDateUserPrivacyRestricted. const MessageReadDateUserPrivacyRestrictedTypeID = 0xb38d9426 // construct implements constructor of MessageReadDateClass. func (m MessageReadDateUserPrivacyRestricted) construct() MessageReadDateClass { return &m } // Ensuring interfaces in compile-time for MessageReadDateUserPrivacyRestricted. var ( _ bin.Encoder = &MessageReadDateUserPrivacyRestricted{} _ bin.Decoder = &MessageReadDateUserPrivacyRestricted{} _ bin.BareEncoder = &MessageReadDateUserPrivacyRestricted{} _ bin.BareDecoder = &MessageReadDateUserPrivacyRestricted{} _ MessageReadDateClass = &MessageReadDateUserPrivacyRestricted{} ) func (m *MessageReadDateUserPrivacyRestricted) Zero() bool { if m == nil { return true } return true } // String implements fmt.Stringer. func (m *MessageReadDateUserPrivacyRestricted) String() string { if m == nil { return "MessageReadDateUserPrivacyRestricted(nil)" } type Alias MessageReadDateUserPrivacyRestricted return fmt.Sprintf("MessageReadDateUserPrivacyRestricted%+v", Alias(*m)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*MessageReadDateUserPrivacyRestricted) TypeID() uint32 { return MessageReadDateUserPrivacyRestrictedTypeID } // TypeName returns name of type in TL schema. func (*MessageReadDateUserPrivacyRestricted) TypeName() string { return "messageReadDateUserPrivacyRestricted" } // TypeInfo returns info about TL type. func (m *MessageReadDateUserPrivacyRestricted) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "messageReadDateUserPrivacyRestricted", ID: MessageReadDateUserPrivacyRestrictedTypeID, } if m == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (m *MessageReadDateUserPrivacyRestricted) Encode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateUserPrivacyRestricted#b38d9426 as nil") } b.PutID(MessageReadDateUserPrivacyRestrictedTypeID) return m.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (m *MessageReadDateUserPrivacyRestricted) EncodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateUserPrivacyRestricted#b38d9426 as nil") } return nil } // Decode implements bin.Decoder. func (m *MessageReadDateUserPrivacyRestricted) Decode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateUserPrivacyRestricted#b38d9426 to nil") } if err := b.ConsumeID(MessageReadDateUserPrivacyRestrictedTypeID); err != nil { return fmt.Errorf("unable to decode messageReadDateUserPrivacyRestricted#b38d9426: %w", err) } return m.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (m *MessageReadDateUserPrivacyRestricted) DecodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateUserPrivacyRestricted#b38d9426 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (m *MessageReadDateUserPrivacyRestricted) EncodeTDLibJSON(b tdjson.Encoder) error { if m == nil { return fmt.Errorf("can't encode messageReadDateUserPrivacyRestricted#b38d9426 as nil") } b.ObjStart() b.PutID("messageReadDateUserPrivacyRestricted") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (m *MessageReadDateUserPrivacyRestricted) DecodeTDLibJSON(b tdjson.Decoder) error { if m == nil { return fmt.Errorf("can't decode messageReadDateUserPrivacyRestricted#b38d9426 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("messageReadDateUserPrivacyRestricted"); err != nil { return fmt.Errorf("unable to decode messageReadDateUserPrivacyRestricted#b38d9426: %w", err) } default: return b.Skip() } return nil }) } // MessageReadDateMyPrivacyRestricted represents TL type `messageReadDateMyPrivacyRestricted#d6a2d474`. type MessageReadDateMyPrivacyRestricted struct { } // MessageReadDateMyPrivacyRestrictedTypeID is TL type id of MessageReadDateMyPrivacyRestricted. const MessageReadDateMyPrivacyRestrictedTypeID = 0xd6a2d474 // construct implements constructor of MessageReadDateClass. func (m MessageReadDateMyPrivacyRestricted) construct() MessageReadDateClass { return &m } // Ensuring interfaces in compile-time for MessageReadDateMyPrivacyRestricted. var ( _ bin.Encoder = &MessageReadDateMyPrivacyRestricted{} _ bin.Decoder = &MessageReadDateMyPrivacyRestricted{} _ bin.BareEncoder = &MessageReadDateMyPrivacyRestricted{} _ bin.BareDecoder = &MessageReadDateMyPrivacyRestricted{} _ MessageReadDateClass = &MessageReadDateMyPrivacyRestricted{} ) func (m *MessageReadDateMyPrivacyRestricted) Zero() bool { if m == nil { return true } return true } // String implements fmt.Stringer. func (m *MessageReadDateMyPrivacyRestricted) String() string { if m == nil { return "MessageReadDateMyPrivacyRestricted(nil)" } type Alias MessageReadDateMyPrivacyRestricted return fmt.Sprintf("MessageReadDateMyPrivacyRestricted%+v", Alias(*m)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*MessageReadDateMyPrivacyRestricted) TypeID() uint32 { return MessageReadDateMyPrivacyRestrictedTypeID } // TypeName returns name of type in TL schema. func (*MessageReadDateMyPrivacyRestricted) TypeName() string { return "messageReadDateMyPrivacyRestricted" } // TypeInfo returns info about TL type. func (m *MessageReadDateMyPrivacyRestricted) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "messageReadDateMyPrivacyRestricted", ID: MessageReadDateMyPrivacyRestrictedTypeID, } if m == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (m *MessageReadDateMyPrivacyRestricted) Encode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateMyPrivacyRestricted#d6a2d474 as nil") } b.PutID(MessageReadDateMyPrivacyRestrictedTypeID) return m.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (m *MessageReadDateMyPrivacyRestricted) EncodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't encode messageReadDateMyPrivacyRestricted#d6a2d474 as nil") } return nil } // Decode implements bin.Decoder. func (m *MessageReadDateMyPrivacyRestricted) Decode(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateMyPrivacyRestricted#d6a2d474 to nil") } if err := b.ConsumeID(MessageReadDateMyPrivacyRestrictedTypeID); err != nil { return fmt.Errorf("unable to decode messageReadDateMyPrivacyRestricted#d6a2d474: %w", err) } return m.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (m *MessageReadDateMyPrivacyRestricted) DecodeBare(b *bin.Buffer) error { if m == nil { return fmt.Errorf("can't decode messageReadDateMyPrivacyRestricted#d6a2d474 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (m *MessageReadDateMyPrivacyRestricted) EncodeTDLibJSON(b tdjson.Encoder) error { if m == nil { return fmt.Errorf("can't encode messageReadDateMyPrivacyRestricted#d6a2d474 as nil") } b.ObjStart() b.PutID("messageReadDateMyPrivacyRestricted") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (m *MessageReadDateMyPrivacyRestricted) DecodeTDLibJSON(b tdjson.Decoder) error { if m == nil { return fmt.Errorf("can't decode messageReadDateMyPrivacyRestricted#d6a2d474 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("messageReadDateMyPrivacyRestricted"); err != nil { return fmt.Errorf("unable to decode messageReadDateMyPrivacyRestricted#d6a2d474: %w", err) } default: return b.Skip() } return nil }) } // MessageReadDateClassName is schema name of MessageReadDateClass. const MessageReadDateClassName = "MessageReadDate" // MessageReadDateClass represents MessageReadDate generic type. // // Example: // // g, err := tdapi.DecodeMessageReadDate(buf) // if err != nil { // panic(err) // } // switch v := g.(type) { // case *tdapi.MessageReadDateRead: // messageReadDateRead#758d2e30 // case *tdapi.MessageReadDateUnread: // messageReadDateUnread#17b2212c // case *tdapi.MessageReadDateTooOld: // messageReadDateTooOld#b6761e20 // case *tdapi.MessageReadDateUserPrivacyRestricted: // messageReadDateUserPrivacyRestricted#b38d9426 // case *tdapi.MessageReadDateMyPrivacyRestricted: // messageReadDateMyPrivacyRestricted#d6a2d474 // default: panic(v) // } type MessageReadDateClass interface { bin.Encoder bin.Decoder bin.BareEncoder bin.BareDecoder construct() MessageReadDateClass // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. TypeID() uint32 // TypeName returns name of type in TL schema. TypeName() string // String implements fmt.Stringer. String() string // Zero returns true if current object has a zero value. Zero() bool EncodeTDLibJSON(b tdjson.Encoder) error DecodeTDLibJSON(b tdjson.Decoder) error } // DecodeMessageReadDate implements binary de-serialization for MessageReadDateClass. func DecodeMessageReadDate(buf *bin.Buffer) (MessageReadDateClass, error) { id, err := buf.PeekID() if err != nil { return nil, err } switch id { case MessageReadDateReadTypeID: // Decoding messageReadDateRead#758d2e30. v := MessageReadDateRead{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil case MessageReadDateUnreadTypeID: // Decoding messageReadDateUnread#17b2212c. v := MessageReadDateUnread{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil case MessageReadDateTooOldTypeID: // Decoding messageReadDateTooOld#b6761e20. v := MessageReadDateTooOld{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil case MessageReadDateUserPrivacyRestrictedTypeID: // Decoding messageReadDateUserPrivacyRestricted#b38d9426. v := MessageReadDateUserPrivacyRestricted{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil case MessageReadDateMyPrivacyRestrictedTypeID: // Decoding messageReadDateMyPrivacyRestricted#d6a2d474. v := MessageReadDateMyPrivacyRestricted{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", bin.NewUnexpectedID(id)) } } // DecodeTDLibJSONMessageReadDate implements binary de-serialization for MessageReadDateClass. func DecodeTDLibJSONMessageReadDate(buf tdjson.Decoder) (MessageReadDateClass, error) { id, err := buf.FindTypeID() if err != nil { return nil, err } switch id { case "messageReadDateRead": // Decoding messageReadDateRead#758d2e30. v := MessageReadDateRead{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil case "messageReadDateUnread": // Decoding messageReadDateUnread#17b2212c. v := MessageReadDateUnread{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil case "messageReadDateTooOld": // Decoding messageReadDateTooOld#b6761e20. v := MessageReadDateTooOld{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil case "messageReadDateUserPrivacyRestricted": // Decoding messageReadDateUserPrivacyRestricted#b38d9426. v := MessageReadDateUserPrivacyRestricted{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil case "messageReadDateMyPrivacyRestricted": // Decoding messageReadDateMyPrivacyRestricted#d6a2d474. v := MessageReadDateMyPrivacyRestricted{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode MessageReadDateClass: %w", tdjson.NewUnexpectedID(id)) } } // MessageReadDate boxes the MessageReadDateClass providing a helper. type MessageReadDateBox struct { MessageReadDate MessageReadDateClass } // Decode implements bin.Decoder for MessageReadDateBox. func (b *MessageReadDateBox) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("unable to decode MessageReadDateBox to nil") } v, err := DecodeMessageReadDate(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.MessageReadDate = v return nil } // Encode implements bin.Encode for MessageReadDateBox. func (b *MessageReadDateBox) Encode(buf *bin.Buffer) error { if b == nil || b.MessageReadDate == nil { return fmt.Errorf("unable to encode MessageReadDateClass as nil") } return b.MessageReadDate.Encode(buf) } // DecodeTDLibJSON implements bin.Decoder for MessageReadDateBox. func (b *MessageReadDateBox) DecodeTDLibJSON(buf tdjson.Decoder) error { if b == nil { return fmt.Errorf("unable to decode MessageReadDateBox to nil") } v, err := DecodeTDLibJSONMessageReadDate(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.MessageReadDate = v return nil } // EncodeTDLibJSON implements bin.Encode for MessageReadDateBox. func (b *MessageReadDateBox) EncodeTDLibJSON(buf tdjson.Encoder) error { if b == nil || b.MessageReadDate == nil { return fmt.Errorf("unable to encode MessageReadDateClass as nil") } return b.MessageReadDate.EncodeTDLibJSON(buf) }