// 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{} ) // FutureSalts represents TL type `future_salts#ae500895`. type FutureSalts struct { // ReqMsgID field of FutureSalts. ReqMsgID int64 // Now field of FutureSalts. Now int // Salts field of FutureSalts. Salts []FutureSalt } // FutureSaltsTypeID is TL type id of FutureSalts. const FutureSaltsTypeID = 0xae500895 // Ensuring interfaces in compile-time for FutureSalts. var ( _ bin.Encoder = &FutureSalts{} _ bin.Decoder = &FutureSalts{} _ bin.BareEncoder = &FutureSalts{} _ bin.BareDecoder = &FutureSalts{} ) func (f *FutureSalts) Zero() bool { if f == nil { return true } if !(f.ReqMsgID == 0) { return false } if !(f.Now == 0) { return false } if !(f.Salts == nil) { return false } return true } // String implements fmt.Stringer. func (f *FutureSalts) String() string { if f == nil { return "FutureSalts(nil)" } type Alias FutureSalts return fmt.Sprintf("FutureSalts%+v", Alias(*f)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*FutureSalts) TypeID() uint32 { return FutureSaltsTypeID } // TypeName returns name of type in TL schema. func (*FutureSalts) TypeName() string { return "future_salts" } // TypeInfo returns info about TL type. func (f *FutureSalts) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "future_salts", ID: FutureSaltsTypeID, } if f == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ReqMsgID", SchemaName: "req_msg_id", }, { Name: "Now", SchemaName: "now", }, { Name: "Salts", SchemaName: "salts", }, } return typ } // Encode implements bin.Encoder. func (f *FutureSalts) Encode(b *bin.Buffer) error { if f == nil { return fmt.Errorf("can't encode future_salts#ae500895 as nil") } b.PutID(FutureSaltsTypeID) return f.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (f *FutureSalts) EncodeBare(b *bin.Buffer) error { if f == nil { return fmt.Errorf("can't encode future_salts#ae500895 as nil") } b.PutLong(f.ReqMsgID) b.PutInt(f.Now) b.PutInt(len(f.Salts)) for idx, v := range f.Salts { if err := v.EncodeBare(b); err != nil { return fmt.Errorf("unable to encode bare future_salts#ae500895: field salts element with index %d: %w", idx, err) } } return nil } // Decode implements bin.Decoder. func (f *FutureSalts) Decode(b *bin.Buffer) error { if f == nil { return fmt.Errorf("can't decode future_salts#ae500895 to nil") } if err := b.ConsumeID(FutureSaltsTypeID); err != nil { return fmt.Errorf("unable to decode future_salts#ae500895: %w", err) } return f.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (f *FutureSalts) DecodeBare(b *bin.Buffer) error { if f == nil { return fmt.Errorf("can't decode future_salts#ae500895 to nil") } { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode future_salts#ae500895: field req_msg_id: %w", err) } f.ReqMsgID = value } { value, err := b.Int() if err != nil { return fmt.Errorf("unable to decode future_salts#ae500895: field now: %w", err) } f.Now = value } { headerLen, err := b.Int() if err != nil { return fmt.Errorf("unable to decode future_salts#ae500895: field salts: %w", err) } if headerLen > 0 { f.Salts = make([]FutureSalt, 0, headerLen%bin.PreallocateLimit) } for idx := 0; idx < headerLen; idx++ { var value FutureSalt if err := value.DecodeBare(b); err != nil { return fmt.Errorf("unable to decode bare future_salts#ae500895: field salts: %w", err) } f.Salts = append(f.Salts, value) } } return nil } // GetReqMsgID returns value of ReqMsgID field. func (f *FutureSalts) GetReqMsgID() (value int64) { if f == nil { return } return f.ReqMsgID } // GetNow returns value of Now field. func (f *FutureSalts) GetNow() (value int) { if f == nil { return } return f.Now } // GetSalts returns value of Salts field. func (f *FutureSalts) GetSalts() (value []FutureSalt) { if f == nil { return } return f.Salts }