// 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{} ) // ReactionNotificationSourceNone represents TL type `reactionNotificationSourceNone#15d6701c`. type ReactionNotificationSourceNone struct { } // ReactionNotificationSourceNoneTypeID is TL type id of ReactionNotificationSourceNone. const ReactionNotificationSourceNoneTypeID = 0x15d6701c // construct implements constructor of ReactionNotificationSourceClass. func (r ReactionNotificationSourceNone) construct() ReactionNotificationSourceClass { return &r } // Ensuring interfaces in compile-time for ReactionNotificationSourceNone. var ( _ bin.Encoder = &ReactionNotificationSourceNone{} _ bin.Decoder = &ReactionNotificationSourceNone{} _ bin.BareEncoder = &ReactionNotificationSourceNone{} _ bin.BareDecoder = &ReactionNotificationSourceNone{} _ ReactionNotificationSourceClass = &ReactionNotificationSourceNone{} ) func (r *ReactionNotificationSourceNone) Zero() bool { if r == nil { return true } return true } // String implements fmt.Stringer. func (r *ReactionNotificationSourceNone) String() string { if r == nil { return "ReactionNotificationSourceNone(nil)" } type Alias ReactionNotificationSourceNone return fmt.Sprintf("ReactionNotificationSourceNone%+v", Alias(*r)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ReactionNotificationSourceNone) TypeID() uint32 { return ReactionNotificationSourceNoneTypeID } // TypeName returns name of type in TL schema. func (*ReactionNotificationSourceNone) TypeName() string { return "reactionNotificationSourceNone" } // TypeInfo returns info about TL type. func (r *ReactionNotificationSourceNone) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "reactionNotificationSourceNone", ID: ReactionNotificationSourceNoneTypeID, } if r == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (r *ReactionNotificationSourceNone) Encode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceNone#15d6701c as nil") } b.PutID(ReactionNotificationSourceNoneTypeID) return r.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (r *ReactionNotificationSourceNone) EncodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceNone#15d6701c as nil") } return nil } // Decode implements bin.Decoder. func (r *ReactionNotificationSourceNone) Decode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceNone#15d6701c to nil") } if err := b.ConsumeID(ReactionNotificationSourceNoneTypeID); err != nil { return fmt.Errorf("unable to decode reactionNotificationSourceNone#15d6701c: %w", err) } return r.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (r *ReactionNotificationSourceNone) DecodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceNone#15d6701c to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (r *ReactionNotificationSourceNone) EncodeTDLibJSON(b tdjson.Encoder) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceNone#15d6701c as nil") } b.ObjStart() b.PutID("reactionNotificationSourceNone") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (r *ReactionNotificationSourceNone) DecodeTDLibJSON(b tdjson.Decoder) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceNone#15d6701c to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("reactionNotificationSourceNone"); err != nil { return fmt.Errorf("unable to decode reactionNotificationSourceNone#15d6701c: %w", err) } default: return b.Skip() } return nil }) } // ReactionNotificationSourceContacts represents TL type `reactionNotificationSourceContacts#211c4835`. type ReactionNotificationSourceContacts struct { } // ReactionNotificationSourceContactsTypeID is TL type id of ReactionNotificationSourceContacts. const ReactionNotificationSourceContactsTypeID = 0x211c4835 // construct implements constructor of ReactionNotificationSourceClass. func (r ReactionNotificationSourceContacts) construct() ReactionNotificationSourceClass { return &r } // Ensuring interfaces in compile-time for ReactionNotificationSourceContacts. var ( _ bin.Encoder = &ReactionNotificationSourceContacts{} _ bin.Decoder = &ReactionNotificationSourceContacts{} _ bin.BareEncoder = &ReactionNotificationSourceContacts{} _ bin.BareDecoder = &ReactionNotificationSourceContacts{} _ ReactionNotificationSourceClass = &ReactionNotificationSourceContacts{} ) func (r *ReactionNotificationSourceContacts) Zero() bool { if r == nil { return true } return true } // String implements fmt.Stringer. func (r *ReactionNotificationSourceContacts) String() string { if r == nil { return "ReactionNotificationSourceContacts(nil)" } type Alias ReactionNotificationSourceContacts return fmt.Sprintf("ReactionNotificationSourceContacts%+v", Alias(*r)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ReactionNotificationSourceContacts) TypeID() uint32 { return ReactionNotificationSourceContactsTypeID } // TypeName returns name of type in TL schema. func (*ReactionNotificationSourceContacts) TypeName() string { return "reactionNotificationSourceContacts" } // TypeInfo returns info about TL type. func (r *ReactionNotificationSourceContacts) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "reactionNotificationSourceContacts", ID: ReactionNotificationSourceContactsTypeID, } if r == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (r *ReactionNotificationSourceContacts) Encode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceContacts#211c4835 as nil") } b.PutID(ReactionNotificationSourceContactsTypeID) return r.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (r *ReactionNotificationSourceContacts) EncodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceContacts#211c4835 as nil") } return nil } // Decode implements bin.Decoder. func (r *ReactionNotificationSourceContacts) Decode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceContacts#211c4835 to nil") } if err := b.ConsumeID(ReactionNotificationSourceContactsTypeID); err != nil { return fmt.Errorf("unable to decode reactionNotificationSourceContacts#211c4835: %w", err) } return r.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (r *ReactionNotificationSourceContacts) DecodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceContacts#211c4835 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (r *ReactionNotificationSourceContacts) EncodeTDLibJSON(b tdjson.Encoder) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceContacts#211c4835 as nil") } b.ObjStart() b.PutID("reactionNotificationSourceContacts") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (r *ReactionNotificationSourceContacts) DecodeTDLibJSON(b tdjson.Decoder) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceContacts#211c4835 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("reactionNotificationSourceContacts"); err != nil { return fmt.Errorf("unable to decode reactionNotificationSourceContacts#211c4835: %w", err) } default: return b.Skip() } return nil }) } // ReactionNotificationSourceAll represents TL type `reactionNotificationSourceAll#4a02ac92`. type ReactionNotificationSourceAll struct { } // ReactionNotificationSourceAllTypeID is TL type id of ReactionNotificationSourceAll. const ReactionNotificationSourceAllTypeID = 0x4a02ac92 // construct implements constructor of ReactionNotificationSourceClass. func (r ReactionNotificationSourceAll) construct() ReactionNotificationSourceClass { return &r } // Ensuring interfaces in compile-time for ReactionNotificationSourceAll. var ( _ bin.Encoder = &ReactionNotificationSourceAll{} _ bin.Decoder = &ReactionNotificationSourceAll{} _ bin.BareEncoder = &ReactionNotificationSourceAll{} _ bin.BareDecoder = &ReactionNotificationSourceAll{} _ ReactionNotificationSourceClass = &ReactionNotificationSourceAll{} ) func (r *ReactionNotificationSourceAll) Zero() bool { if r == nil { return true } return true } // String implements fmt.Stringer. func (r *ReactionNotificationSourceAll) String() string { if r == nil { return "ReactionNotificationSourceAll(nil)" } type Alias ReactionNotificationSourceAll return fmt.Sprintf("ReactionNotificationSourceAll%+v", Alias(*r)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ReactionNotificationSourceAll) TypeID() uint32 { return ReactionNotificationSourceAllTypeID } // TypeName returns name of type in TL schema. func (*ReactionNotificationSourceAll) TypeName() string { return "reactionNotificationSourceAll" } // TypeInfo returns info about TL type. func (r *ReactionNotificationSourceAll) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "reactionNotificationSourceAll", ID: ReactionNotificationSourceAllTypeID, } if r == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (r *ReactionNotificationSourceAll) Encode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceAll#4a02ac92 as nil") } b.PutID(ReactionNotificationSourceAllTypeID) return r.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (r *ReactionNotificationSourceAll) EncodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceAll#4a02ac92 as nil") } return nil } // Decode implements bin.Decoder. func (r *ReactionNotificationSourceAll) Decode(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceAll#4a02ac92 to nil") } if err := b.ConsumeID(ReactionNotificationSourceAllTypeID); err != nil { return fmt.Errorf("unable to decode reactionNotificationSourceAll#4a02ac92: %w", err) } return r.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (r *ReactionNotificationSourceAll) DecodeBare(b *bin.Buffer) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceAll#4a02ac92 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (r *ReactionNotificationSourceAll) EncodeTDLibJSON(b tdjson.Encoder) error { if r == nil { return fmt.Errorf("can't encode reactionNotificationSourceAll#4a02ac92 as nil") } b.ObjStart() b.PutID("reactionNotificationSourceAll") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (r *ReactionNotificationSourceAll) DecodeTDLibJSON(b tdjson.Decoder) error { if r == nil { return fmt.Errorf("can't decode reactionNotificationSourceAll#4a02ac92 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("reactionNotificationSourceAll"); err != nil { return fmt.Errorf("unable to decode reactionNotificationSourceAll#4a02ac92: %w", err) } default: return b.Skip() } return nil }) } // ReactionNotificationSourceClassName is schema name of ReactionNotificationSourceClass. const ReactionNotificationSourceClassName = "ReactionNotificationSource" // ReactionNotificationSourceClass represents ReactionNotificationSource generic type. // // Example: // // g, err := tdapi.DecodeReactionNotificationSource(buf) // if err != nil { // panic(err) // } // switch v := g.(type) { // case *tdapi.ReactionNotificationSourceNone: // reactionNotificationSourceNone#15d6701c // case *tdapi.ReactionNotificationSourceContacts: // reactionNotificationSourceContacts#211c4835 // case *tdapi.ReactionNotificationSourceAll: // reactionNotificationSourceAll#4a02ac92 // default: panic(v) // } type ReactionNotificationSourceClass interface { bin.Encoder bin.Decoder bin.BareEncoder bin.BareDecoder construct() ReactionNotificationSourceClass // 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 } // DecodeReactionNotificationSource implements binary de-serialization for ReactionNotificationSourceClass. func DecodeReactionNotificationSource(buf *bin.Buffer) (ReactionNotificationSourceClass, error) { id, err := buf.PeekID() if err != nil { return nil, err } switch id { case ReactionNotificationSourceNoneTypeID: // Decoding reactionNotificationSourceNone#15d6701c. v := ReactionNotificationSourceNone{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ReactionNotificationSourceClass: %w", err) } return &v, nil case ReactionNotificationSourceContactsTypeID: // Decoding reactionNotificationSourceContacts#211c4835. v := ReactionNotificationSourceContacts{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ReactionNotificationSourceClass: %w", err) } return &v, nil case ReactionNotificationSourceAllTypeID: // Decoding reactionNotificationSourceAll#4a02ac92. v := ReactionNotificationSourceAll{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode ReactionNotificationSourceClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode ReactionNotificationSourceClass: %w", bin.NewUnexpectedID(id)) } } // DecodeTDLibJSONReactionNotificationSource implements binary de-serialization for ReactionNotificationSourceClass. func DecodeTDLibJSONReactionNotificationSource(buf tdjson.Decoder) (ReactionNotificationSourceClass, error) { id, err := buf.FindTypeID() if err != nil { return nil, err } switch id { case "reactionNotificationSourceNone": // Decoding reactionNotificationSourceNone#15d6701c. v := ReactionNotificationSourceNone{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode ReactionNotificationSourceClass: %w", err) } return &v, nil case "reactionNotificationSourceContacts": // Decoding reactionNotificationSourceContacts#211c4835. v := ReactionNotificationSourceContacts{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode ReactionNotificationSourceClass: %w", err) } return &v, nil case "reactionNotificationSourceAll": // Decoding reactionNotificationSourceAll#4a02ac92. v := ReactionNotificationSourceAll{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode ReactionNotificationSourceClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode ReactionNotificationSourceClass: %w", tdjson.NewUnexpectedID(id)) } } // ReactionNotificationSource boxes the ReactionNotificationSourceClass providing a helper. type ReactionNotificationSourceBox struct { ReactionNotificationSource ReactionNotificationSourceClass } // Decode implements bin.Decoder for ReactionNotificationSourceBox. func (b *ReactionNotificationSourceBox) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("unable to decode ReactionNotificationSourceBox to nil") } v, err := DecodeReactionNotificationSource(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.ReactionNotificationSource = v return nil } // Encode implements bin.Encode for ReactionNotificationSourceBox. func (b *ReactionNotificationSourceBox) Encode(buf *bin.Buffer) error { if b == nil || b.ReactionNotificationSource == nil { return fmt.Errorf("unable to encode ReactionNotificationSourceClass as nil") } return b.ReactionNotificationSource.Encode(buf) } // DecodeTDLibJSON implements bin.Decoder for ReactionNotificationSourceBox. func (b *ReactionNotificationSourceBox) DecodeTDLibJSON(buf tdjson.Decoder) error { if b == nil { return fmt.Errorf("unable to decode ReactionNotificationSourceBox to nil") } v, err := DecodeTDLibJSONReactionNotificationSource(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.ReactionNotificationSource = v return nil } // EncodeTDLibJSON implements bin.Encode for ReactionNotificationSourceBox. func (b *ReactionNotificationSourceBox) EncodeTDLibJSON(buf tdjson.Encoder) error { if b == nil || b.ReactionNotificationSource == nil { return fmt.Errorf("unable to encode ReactionNotificationSourceClass as nil") } return b.ReactionNotificationSource.EncodeTDLibJSON(buf) }