// 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{} ) // PreparedInlineMessageID represents TL type `preparedInlineMessageId#380d9be4`. type PreparedInlineMessageID struct { // Unique identifier for the message ID string // Point in time (Unix timestamp) when the message can't be used anymore ExpirationDate int32 } // PreparedInlineMessageIDTypeID is TL type id of PreparedInlineMessageID. const PreparedInlineMessageIDTypeID = 0x380d9be4 // Ensuring interfaces in compile-time for PreparedInlineMessageID. var ( _ bin.Encoder = &PreparedInlineMessageID{} _ bin.Decoder = &PreparedInlineMessageID{} _ bin.BareEncoder = &PreparedInlineMessageID{} _ bin.BareDecoder = &PreparedInlineMessageID{} ) func (p *PreparedInlineMessageID) Zero() bool { if p == nil { return true } if !(p.ID == "") { return false } if !(p.ExpirationDate == 0) { return false } return true } // String implements fmt.Stringer. func (p *PreparedInlineMessageID) String() string { if p == nil { return "PreparedInlineMessageID(nil)" } type Alias PreparedInlineMessageID return fmt.Sprintf("PreparedInlineMessageID%+v", Alias(*p)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*PreparedInlineMessageID) TypeID() uint32 { return PreparedInlineMessageIDTypeID } // TypeName returns name of type in TL schema. func (*PreparedInlineMessageID) TypeName() string { return "preparedInlineMessageId" } // TypeInfo returns info about TL type. func (p *PreparedInlineMessageID) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "preparedInlineMessageId", ID: PreparedInlineMessageIDTypeID, } if p == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ID", SchemaName: "id", }, { Name: "ExpirationDate", SchemaName: "expiration_date", }, } return typ } // Encode implements bin.Encoder. func (p *PreparedInlineMessageID) Encode(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't encode preparedInlineMessageId#380d9be4 as nil") } b.PutID(PreparedInlineMessageIDTypeID) return p.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (p *PreparedInlineMessageID) EncodeBare(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't encode preparedInlineMessageId#380d9be4 as nil") } b.PutString(p.ID) b.PutInt32(p.ExpirationDate) return nil } // Decode implements bin.Decoder. func (p *PreparedInlineMessageID) Decode(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't decode preparedInlineMessageId#380d9be4 to nil") } if err := b.ConsumeID(PreparedInlineMessageIDTypeID); err != nil { return fmt.Errorf("unable to decode preparedInlineMessageId#380d9be4: %w", err) } return p.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (p *PreparedInlineMessageID) DecodeBare(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't decode preparedInlineMessageId#380d9be4 to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode preparedInlineMessageId#380d9be4: field id: %w", err) } p.ID = value } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode preparedInlineMessageId#380d9be4: field expiration_date: %w", err) } p.ExpirationDate = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (p *PreparedInlineMessageID) EncodeTDLibJSON(b tdjson.Encoder) error { if p == nil { return fmt.Errorf("can't encode preparedInlineMessageId#380d9be4 as nil") } b.ObjStart() b.PutID("preparedInlineMessageId") b.Comma() b.FieldStart("id") b.PutString(p.ID) b.Comma() b.FieldStart("expiration_date") b.PutInt32(p.ExpirationDate) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (p *PreparedInlineMessageID) DecodeTDLibJSON(b tdjson.Decoder) error { if p == nil { return fmt.Errorf("can't decode preparedInlineMessageId#380d9be4 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("preparedInlineMessageId"); err != nil { return fmt.Errorf("unable to decode preparedInlineMessageId#380d9be4: %w", err) } case "id": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode preparedInlineMessageId#380d9be4: field id: %w", err) } p.ID = value case "expiration_date": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode preparedInlineMessageId#380d9be4: field expiration_date: %w", err) } p.ExpirationDate = value default: return b.Skip() } return nil }) } // GetID returns value of ID field. func (p *PreparedInlineMessageID) GetID() (value string) { if p == nil { return } return p.ID } // GetExpirationDate returns value of ExpirationDate field. func (p *PreparedInlineMessageID) GetExpirationDate() (value int32) { if p == nil { return } return p.ExpirationDate }