// Code generated by gotdgen, DO NOT EDIT. package mt 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{} ) // BadMsgNotification represents TL type `bad_msg_notification#a7eff811`. type BadMsgNotification struct { // BadMsgID field of BadMsgNotification. BadMsgID int64 // BadMsgSeqno field of BadMsgNotification. BadMsgSeqno int // ErrorCode field of BadMsgNotification. ErrorCode int } // BadMsgNotificationTypeID is TL type id of BadMsgNotification. const BadMsgNotificationTypeID = 0xa7eff811 // construct implements constructor of BadMsgNotificationClass. func (b BadMsgNotification) construct() BadMsgNotificationClass { return &b } // Ensuring interfaces in compile-time for BadMsgNotification. var ( _ bin.Encoder = &BadMsgNotification{} _ bin.Decoder = &BadMsgNotification{} _ bin.BareEncoder = &BadMsgNotification{} _ bin.BareDecoder = &BadMsgNotification{} _ BadMsgNotificationClass = &BadMsgNotification{} ) func (b *BadMsgNotification) Zero() bool { if b == nil { return true } if !(b.BadMsgID == 0) { return false } if !(b.BadMsgSeqno == 0) { return false } if !(b.ErrorCode == 0) { return false } return true } // String implements fmt.Stringer. func (b *BadMsgNotification) String() string { if b == nil { return "BadMsgNotification(nil)" } type Alias BadMsgNotification return fmt.Sprintf("BadMsgNotification%+v", Alias(*b)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*BadMsgNotification) TypeID() uint32 { return BadMsgNotificationTypeID } // TypeName returns name of type in TL schema. func (*BadMsgNotification) TypeName() string { return "bad_msg_notification" } // TypeInfo returns info about TL type. func (b *BadMsgNotification) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "bad_msg_notification", ID: BadMsgNotificationTypeID, } if b == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "BadMsgID", SchemaName: "bad_msg_id", }, { Name: "BadMsgSeqno", SchemaName: "bad_msg_seqno", }, { Name: "ErrorCode", SchemaName: "error_code", }, } return typ } // Encode implements bin.Encoder. func (b *BadMsgNotification) Encode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode bad_msg_notification#a7eff811 as nil") } buf.PutID(BadMsgNotificationTypeID) return b.EncodeBare(buf) } // EncodeBare implements bin.BareEncoder. func (b *BadMsgNotification) EncodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode bad_msg_notification#a7eff811 as nil") } buf.PutLong(b.BadMsgID) buf.PutInt(b.BadMsgSeqno) buf.PutInt(b.ErrorCode) return nil } // Decode implements bin.Decoder. func (b *BadMsgNotification) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode bad_msg_notification#a7eff811 to nil") } if err := buf.ConsumeID(BadMsgNotificationTypeID); err != nil { return fmt.Errorf("unable to decode bad_msg_notification#a7eff811: %w", err) } return b.DecodeBare(buf) } // DecodeBare implements bin.BareDecoder. func (b *BadMsgNotification) DecodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode bad_msg_notification#a7eff811 to nil") } { value, err := buf.Long() if err != nil { return fmt.Errorf("unable to decode bad_msg_notification#a7eff811: field bad_msg_id: %w", err) } b.BadMsgID = value } { value, err := buf.Int() if err != nil { return fmt.Errorf("unable to decode bad_msg_notification#a7eff811: field bad_msg_seqno: %w", err) } b.BadMsgSeqno = value } { value, err := buf.Int() if err != nil { return fmt.Errorf("unable to decode bad_msg_notification#a7eff811: field error_code: %w", err) } b.ErrorCode = value } return nil } // GetBadMsgID returns value of BadMsgID field. func (b *BadMsgNotification) GetBadMsgID() (value int64) { if b == nil { return } return b.BadMsgID } // GetBadMsgSeqno returns value of BadMsgSeqno field. func (b *BadMsgNotification) GetBadMsgSeqno() (value int) { if b == nil { return } return b.BadMsgSeqno } // GetErrorCode returns value of ErrorCode field. func (b *BadMsgNotification) GetErrorCode() (value int) { if b == nil { return } return b.ErrorCode } // BadServerSalt represents TL type `bad_server_salt#edab447b`. type BadServerSalt struct { // BadMsgID field of BadServerSalt. BadMsgID int64 // BadMsgSeqno field of BadServerSalt. BadMsgSeqno int // ErrorCode field of BadServerSalt. ErrorCode int // NewServerSalt field of BadServerSalt. NewServerSalt int64 } // BadServerSaltTypeID is TL type id of BadServerSalt. const BadServerSaltTypeID = 0xedab447b // construct implements constructor of BadMsgNotificationClass. func (b BadServerSalt) construct() BadMsgNotificationClass { return &b } // Ensuring interfaces in compile-time for BadServerSalt. var ( _ bin.Encoder = &BadServerSalt{} _ bin.Decoder = &BadServerSalt{} _ bin.BareEncoder = &BadServerSalt{} _ bin.BareDecoder = &BadServerSalt{} _ BadMsgNotificationClass = &BadServerSalt{} ) func (b *BadServerSalt) Zero() bool { if b == nil { return true } if !(b.BadMsgID == 0) { return false } if !(b.BadMsgSeqno == 0) { return false } if !(b.ErrorCode == 0) { return false } if !(b.NewServerSalt == 0) { return false } return true } // String implements fmt.Stringer. func (b *BadServerSalt) String() string { if b == nil { return "BadServerSalt(nil)" } type Alias BadServerSalt return fmt.Sprintf("BadServerSalt%+v", Alias(*b)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*BadServerSalt) TypeID() uint32 { return BadServerSaltTypeID } // TypeName returns name of type in TL schema. func (*BadServerSalt) TypeName() string { return "bad_server_salt" } // TypeInfo returns info about TL type. func (b *BadServerSalt) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "bad_server_salt", ID: BadServerSaltTypeID, } if b == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "BadMsgID", SchemaName: "bad_msg_id", }, { Name: "BadMsgSeqno", SchemaName: "bad_msg_seqno", }, { Name: "ErrorCode", SchemaName: "error_code", }, { Name: "NewServerSalt", SchemaName: "new_server_salt", }, } return typ } // Encode implements bin.Encoder. func (b *BadServerSalt) Encode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode bad_server_salt#edab447b as nil") } buf.PutID(BadServerSaltTypeID) return b.EncodeBare(buf) } // EncodeBare implements bin.BareEncoder. func (b *BadServerSalt) EncodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode bad_server_salt#edab447b as nil") } buf.PutLong(b.BadMsgID) buf.PutInt(b.BadMsgSeqno) buf.PutInt(b.ErrorCode) buf.PutLong(b.NewServerSalt) return nil } // Decode implements bin.Decoder. func (b *BadServerSalt) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode bad_server_salt#edab447b to nil") } if err := buf.ConsumeID(BadServerSaltTypeID); err != nil { return fmt.Errorf("unable to decode bad_server_salt#edab447b: %w", err) } return b.DecodeBare(buf) } // DecodeBare implements bin.BareDecoder. func (b *BadServerSalt) DecodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode bad_server_salt#edab447b to nil") } { value, err := buf.Long() if err != nil { return fmt.Errorf("unable to decode bad_server_salt#edab447b: field bad_msg_id: %w", err) } b.BadMsgID = value } { value, err := buf.Int() if err != nil { return fmt.Errorf("unable to decode bad_server_salt#edab447b: field bad_msg_seqno: %w", err) } b.BadMsgSeqno = value } { value, err := buf.Int() if err != nil { return fmt.Errorf("unable to decode bad_server_salt#edab447b: field error_code: %w", err) } b.ErrorCode = value } { value, err := buf.Long() if err != nil { return fmt.Errorf("unable to decode bad_server_salt#edab447b: field new_server_salt: %w", err) } b.NewServerSalt = value } return nil } // GetBadMsgID returns value of BadMsgID field. func (b *BadServerSalt) GetBadMsgID() (value int64) { if b == nil { return } return b.BadMsgID } // GetBadMsgSeqno returns value of BadMsgSeqno field. func (b *BadServerSalt) GetBadMsgSeqno() (value int) { if b == nil { return } return b.BadMsgSeqno } // GetErrorCode returns value of ErrorCode field. func (b *BadServerSalt) GetErrorCode() (value int) { if b == nil { return } return b.ErrorCode } // GetNewServerSalt returns value of NewServerSalt field. func (b *BadServerSalt) GetNewServerSalt() (value int64) { if b == nil { return } return b.NewServerSalt } // BadMsgNotificationClassName is schema name of BadMsgNotificationClass. const BadMsgNotificationClassName = "BadMsgNotification" // BadMsgNotificationClass represents BadMsgNotification generic type. // // Example: // // g, err := mt.DecodeBadMsgNotification(buf) // if err != nil { // panic(err) // } // switch v := g.(type) { // case *mt.BadMsgNotification: // bad_msg_notification#a7eff811 // case *mt.BadServerSalt: // bad_server_salt#edab447b // default: panic(v) // } type BadMsgNotificationClass interface { bin.Encoder bin.Decoder bin.BareEncoder bin.BareDecoder construct() BadMsgNotificationClass // 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 // BadMsgID field of BadMsgNotification. GetBadMsgID() (value int64) // BadMsgSeqno field of BadMsgNotification. GetBadMsgSeqno() (value int) // ErrorCode field of BadMsgNotification. GetErrorCode() (value int) } // DecodeBadMsgNotification implements binary de-serialization for BadMsgNotificationClass. func DecodeBadMsgNotification(buf *bin.Buffer) (BadMsgNotificationClass, error) { id, err := buf.PeekID() if err != nil { return nil, err } switch id { case BadMsgNotificationTypeID: // Decoding bad_msg_notification#a7eff811. v := BadMsgNotification{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode BadMsgNotificationClass: %w", err) } return &v, nil case BadServerSaltTypeID: // Decoding bad_server_salt#edab447b. v := BadServerSalt{} if err := v.Decode(buf); err != nil { return nil, fmt.Errorf("unable to decode BadMsgNotificationClass: %w", err) } return &v, nil default: return nil, fmt.Errorf("unable to decode BadMsgNotificationClass: %w", bin.NewUnexpectedID(id)) } } // BadMsgNotification boxes the BadMsgNotificationClass providing a helper. type BadMsgNotificationBox struct { BadMsgNotification BadMsgNotificationClass } // Decode implements bin.Decoder for BadMsgNotificationBox. func (b *BadMsgNotificationBox) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("unable to decode BadMsgNotificationBox to nil") } v, err := DecodeBadMsgNotification(buf) if err != nil { return fmt.Errorf("unable to decode boxed value: %w", err) } b.BadMsgNotification = v return nil } // Encode implements bin.Encode for BadMsgNotificationBox. func (b *BadMsgNotificationBox) Encode(buf *bin.Buffer) error { if b == nil || b.BadMsgNotification == nil { return fmt.Errorf("unable to encode BadMsgNotificationClass as nil") } return b.BadMsgNotification.Encode(buf) }