// 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{} ) // NotificationSettingsScopePrivateChats represents TL type `notificationSettingsScopePrivateChats#37e04d67`. type NotificationSettingsScopePrivateChats struct { } // NotificationSettingsScopePrivateChatsTypeID is TL type id of NotificationSettingsScopePrivateChats. const NotificationSettingsScopePrivateChatsTypeID = 0x37e04d67 // construct implements constructor of NotificationSettingsScopeClass. func (n NotificationSettingsScopePrivateChats) construct() NotificationSettingsScopeClass { return &n } // Ensuring interfaces in compile-time for NotificationSettingsScopePrivateChats. var ( _ bin.Encoder = &NotificationSettingsScopePrivateChats{} _ bin.Decoder = &NotificationSettingsScopePrivateChats{} _ bin.BareEncoder = &NotificationSettingsScopePrivateChats{} _ bin.BareDecoder = &NotificationSettingsScopePrivateChats{} _ NotificationSettingsScopeClass = &NotificationSettingsScopePrivateChats{} ) func (n *NotificationSettingsScopePrivateChats) Zero() bool { if n == nil { return true } return true } // String implements fmt.Stringer. func (n *NotificationSettingsScopePrivateChats) String() string { if n == nil { return "NotificationSettingsScopePrivateChats(nil)" } type Alias NotificationSettingsScopePrivateChats return fmt.Sprintf("NotificationSettingsScopePrivateChats%+v", Alias(*n)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*NotificationSettingsScopePrivateChats) TypeID() uint32 { return NotificationSettingsScopePrivateChatsTypeID } // TypeName returns name of type in TL schema. func (*NotificationSettingsScopePrivateChats) TypeName() string { return "notificationSettingsScopePrivateChats" } // TypeInfo returns info about TL type. func (n *NotificationSettingsScopePrivateChats) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "notificationSettingsScopePrivateChats", ID: NotificationSettingsScopePrivateChatsTypeID, } if n == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (n *NotificationSettingsScopePrivateChats) Encode(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopePrivateChats#37e04d67 as nil") } b.PutID(NotificationSettingsScopePrivateChatsTypeID) return n.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (n *NotificationSettingsScopePrivateChats) EncodeBare(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopePrivateChats#37e04d67 as nil") } return nil } // Decode implements bin.Decoder. func (n *NotificationSettingsScopePrivateChats) Decode(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopePrivateChats#37e04d67 to nil") } if err := b.ConsumeID(NotificationSettingsScopePrivateChatsTypeID); err != nil { return fmt.Errorf("unable to decode notificationSettingsScopePrivateChats#37e04d67: %w", err) } return n.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (n *NotificationSettingsScopePrivateChats) DecodeBare(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopePrivateChats#37e04d67 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (n *NotificationSettingsScopePrivateChats) EncodeTDLibJSON(b tdjson.Encoder) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopePrivateChats#37e04d67 as nil") } b.ObjStart() b.PutID("notificationSettingsScopePrivateChats") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (n *NotificationSettingsScopePrivateChats) DecodeTDLibJSON(b tdjson.Decoder) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopePrivateChats#37e04d67 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("notificationSettingsScopePrivateChats"); err != nil { return fmt.Errorf("unable to decode notificationSettingsScopePrivateChats#37e04d67: %w", err) } default: return b.Skip() } return nil }) } // NotificationSettingsScopeGroupChats represents TL type `notificationSettingsScopeGroupChats#483fd1f3`. type NotificationSettingsScopeGroupChats struct { } // NotificationSettingsScopeGroupChatsTypeID is TL type id of NotificationSettingsScopeGroupChats. const NotificationSettingsScopeGroupChatsTypeID = 0x483fd1f3 // construct implements constructor of NotificationSettingsScopeClass. func (n NotificationSettingsScopeGroupChats) construct() NotificationSettingsScopeClass { return &n } // Ensuring interfaces in compile-time for NotificationSettingsScopeGroupChats. var ( _ bin.Encoder = &NotificationSettingsScopeGroupChats{} _ bin.Decoder = &NotificationSettingsScopeGroupChats{} _ bin.BareEncoder = &NotificationSettingsScopeGroupChats{} _ bin.BareDecoder = &NotificationSettingsScopeGroupChats{} _ NotificationSettingsScopeClass = &NotificationSettingsScopeGroupChats{} ) func (n *NotificationSettingsScopeGroupChats) Zero() bool { if n == nil { return true } return true } // String implements fmt.Stringer. func (n *NotificationSettingsScopeGroupChats) String() string { if n == nil { return "NotificationSettingsScopeGroupChats(nil)" } type Alias NotificationSettingsScopeGroupChats return fmt.Sprintf("NotificationSettingsScopeGroupChats%+v", Alias(*n)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*NotificationSettingsScopeGroupChats) TypeID() uint32 { return NotificationSettingsScopeGroupChatsTypeID } // TypeName returns name of type in TL schema. func (*NotificationSettingsScopeGroupChats) TypeName() string { return "notificationSettingsScopeGroupChats" } // TypeInfo returns info about TL type. func (n *NotificationSettingsScopeGroupChats) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "notificationSettingsScopeGroupChats", ID: NotificationSettingsScopeGroupChatsTypeID, } if n == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (n *NotificationSettingsScopeGroupChats) Encode(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopeGroupChats#483fd1f3 as nil") } b.PutID(NotificationSettingsScopeGroupChatsTypeID) return n.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (n *NotificationSettingsScopeGroupChats) EncodeBare(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopeGroupChats#483fd1f3 as nil") } return nil } // Decode implements bin.Decoder. func (n *NotificationSettingsScopeGroupChats) Decode(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopeGroupChats#483fd1f3 to nil") } if err := b.ConsumeID(NotificationSettingsScopeGroupChatsTypeID); err != nil { return fmt.Errorf("unable to decode notificationSettingsScopeGroupChats#483fd1f3: %w", err) } return n.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (n *NotificationSettingsScopeGroupChats) DecodeBare(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopeGroupChats#483fd1f3 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (n *NotificationSettingsScopeGroupChats) EncodeTDLibJSON(b tdjson.Encoder) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopeGroupChats#483fd1f3 as nil") } b.ObjStart() b.PutID("notificationSettingsScopeGroupChats") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (n *NotificationSettingsScopeGroupChats) DecodeTDLibJSON(b tdjson.Decoder) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopeGroupChats#483fd1f3 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("notificationSettingsScopeGroupChats"); err != nil { return fmt.Errorf("unable to decode notificationSettingsScopeGroupChats#483fd1f3: %w", err) } default: return b.Skip() } return nil }) } // NotificationSettingsScopeChannelChats represents TL type `notificationSettingsScopeChannelChats#20aa0588`. type NotificationSettingsScopeChannelChats struct { } // NotificationSettingsScopeChannelChatsTypeID is TL type id of NotificationSettingsScopeChannelChats. const NotificationSettingsScopeChannelChatsTypeID = 0x20aa0588 // construct implements constructor of NotificationSettingsScopeClass. func (n NotificationSettingsScopeChannelChats) construct() NotificationSettingsScopeClass { return &n } // Ensuring interfaces in compile-time for NotificationSettingsScopeChannelChats. var ( _ bin.Encoder = &NotificationSettingsScopeChannelChats{} _ bin.Decoder = &NotificationSettingsScopeChannelChats{} _ bin.BareEncoder = &NotificationSettingsScopeChannelChats{} _ bin.BareDecoder = &NotificationSettingsScopeChannelChats{} _ NotificationSettingsScopeClass = &NotificationSettingsScopeChannelChats{} ) func (n *NotificationSettingsScopeChannelChats) Zero() bool { if n == nil { return true } return true } // String implements fmt.Stringer. func (n *NotificationSettingsScopeChannelChats) String() string { if n == nil { return "NotificationSettingsScopeChannelChats(nil)" } type Alias NotificationSettingsScopeChannelChats return fmt.Sprintf("NotificationSettingsScopeChannelChats%+v", Alias(*n)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*NotificationSettingsScopeChannelChats) TypeID() uint32 { return NotificationSettingsScopeChannelChatsTypeID } // TypeName returns name of type in TL schema. func (*NotificationSettingsScopeChannelChats) TypeName() string { return "notificationSettingsScopeChannelChats" } // TypeInfo returns info about TL type. func (n *NotificationSettingsScopeChannelChats) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "notificationSettingsScopeChannelChats", ID: NotificationSettingsScopeChannelChatsTypeID, } if n == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{} return typ } // Encode implements bin.Encoder. func (n *NotificationSettingsScopeChannelChats) Encode(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopeChannelChats#20aa0588 as nil") } b.PutID(NotificationSettingsScopeChannelChatsTypeID) return n.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (n *NotificationSettingsScopeChannelChats) EncodeBare(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopeChannelChats#20aa0588 as nil") } return nil } // Decode implements bin.Decoder. func (n *NotificationSettingsScopeChannelChats) Decode(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopeChannelChats#20aa0588 to nil") } if err := b.ConsumeID(NotificationSettingsScopeChannelChatsTypeID); err != nil { return fmt.Errorf("unable to decode notificationSettingsScopeChannelChats#20aa0588: %w", err) } return n.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (n *NotificationSettingsScopeChannelChats) DecodeBare(b *bin.Buffer) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopeChannelChats#20aa0588 to nil") } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (n *NotificationSettingsScopeChannelChats) EncodeTDLibJSON(b tdjson.Encoder) error { if n == nil { return fmt.Errorf("can't encode notificationSettingsScopeChannelChats#20aa0588 as nil") } b.ObjStart() b.PutID("notificationSettingsScopeChannelChats") b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (n *NotificationSettingsScopeChannelChats) DecodeTDLibJSON(b tdjson.Decoder) error { if n == nil { return fmt.Errorf("can't decode notificationSettingsScopeChannelChats#20aa0588 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("notificationSettingsScopeChannelChats"); err != nil { return fmt.Errorf("unable to decode notificationSettingsScopeChannelChats#20aa0588: %w", err) } default: return b.Skip() } return nil }) } // NotificationSettingsScopeClassName is schema name of NotificationSettingsScopeClass. const NotificationSettingsScopeClassName = "NotificationSettingsScope" // NotificationSettingsScopeClass represents NotificationSettingsScope generic type. // // Example: // // g, err := tdapi.DecodeNotificationSettingsScope(buf) // if err != nil { // panic(err) // } // switch v := g.(type) { // case *tdapi.NotificationSettingsScopePrivateChats: // notificationSettingsScopePrivateChats#37e04d67 // case *tdapi.NotificationSettingsScopeGroupChats: // notificationSettingsScopeGroupChats#483fd1f3 // case *tdapi.NotificationSettingsScopeChannelChats: // notificationSettingsScopeChannelChats#20aa0588 // default: panic(v) // } type NotificationSettingsScopeClass interface { bin.Encoder bin.Decoder bin.BareEncoder bin.BareDecoder construct() NotificationSettingsScopeClass // 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 } // DecodeNotificationSettingsScope implements binary de-serialization for NotificationSettingsScopeClass. func DecodeNotificationSettingsScope(buf *bin.Buffer) (NotificationSettingsScopeClass, error) { id, err := buf.PeekID() if err != nil { return nil, err } switch id { case NotificationSettingsScopePrivateChatsTypeID: // Decoding notificationSettingsScopePrivateChats#37e04d67. v := NotificationSettingsScopePrivateChats{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode NotificationSettingsScopeClass: %w", err) } return &v, nil case NotificationSettingsScopeGroupChatsTypeID: // Decoding notificationSettingsScopeGroupChats#483fd1f3. v := NotificationSettingsScopeGroupChats{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode NotificationSettingsScopeClass: %w", err) } return &v, nil case NotificationSettingsScopeChannelChatsTypeID: // Decoding notificationSettingsScopeChannelChats#20aa0588. v := NotificationSettingsScopeChannelChats{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode NotificationSettingsScopeClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode NotificationSettingsScopeClass: %w", bin.NewUnexpectedID(id)) } } // DecodeTDLibJSONNotificationSettingsScope implements binary de-serialization for NotificationSettingsScopeClass. func DecodeTDLibJSONNotificationSettingsScope(buf tdjson.Decoder) (NotificationSettingsScopeClass, error) { id, err := buf.FindTypeID() if err != nil { return nil, err } switch id { case "notificationSettingsScopePrivateChats": // Decoding notificationSettingsScopePrivateChats#37e04d67. v := NotificationSettingsScopePrivateChats{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode NotificationSettingsScopeClass: %w", err) } return &v, nil case "notificationSettingsScopeGroupChats": // Decoding notificationSettingsScopeGroupChats#483fd1f3. v := NotificationSettingsScopeGroupChats{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode NotificationSettingsScopeClass: %w", err) } return &v, nil case "notificationSettingsScopeChannelChats": // Decoding notificationSettingsScopeChannelChats#20aa0588. v := NotificationSettingsScopeChannelChats{} if err := v.DecodeTDLibJSON(buf); err != nil { return nil, fmt.Errorf("unable to decode NotificationSettingsScopeClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode NotificationSettingsScopeClass: %w", tdjson.NewUnexpectedID(id)) } } // NotificationSettingsScope boxes the NotificationSettingsScopeClass providing a helper. type NotificationSettingsScopeBox struct { NotificationSettingsScope NotificationSettingsScopeClass } // Decode implements bin.Decoder for NotificationSettingsScopeBox. func (b *NotificationSettingsScopeBox) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("unable to decode NotificationSettingsScopeBox to nil") } v, err := DecodeNotificationSettingsScope(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.NotificationSettingsScope = v return nil } // Encode implements bin.Encode for NotificationSettingsScopeBox. func (b *NotificationSettingsScopeBox) Encode(buf *bin.Buffer) error { if b == nil || b.NotificationSettingsScope == nil { return fmt.Errorf("unable to encode NotificationSettingsScopeClass as nil") } return b.NotificationSettingsScope.Encode(buf) } // DecodeTDLibJSON implements bin.Decoder for NotificationSettingsScopeBox. func (b *NotificationSettingsScopeBox) DecodeTDLibJSON(buf tdjson.Decoder) error { if b == nil { return fmt.Errorf("unable to decode NotificationSettingsScopeBox to nil") } v, err := DecodeTDLibJSONNotificationSettingsScope(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.NotificationSettingsScope = v return nil } // EncodeTDLibJSON implements bin.Encode for NotificationSettingsScopeBox. func (b *NotificationSettingsScopeBox) EncodeTDLibJSON(buf tdjson.Encoder) error { if b == nil || b.NotificationSettingsScope == nil { return fmt.Errorf("unable to encode NotificationSettingsScopeClass as nil") } return b.NotificationSettingsScope.EncodeTDLibJSON(buf) }