Files
mautrix-telegram/pkg/gotd/tdapi/tl_add_file_to_downloads_gen.go
T
2025-06-27 20:03:37 -07:00

308 lines
7.3 KiB
Go

// 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{}
)
// AddFileToDownloadsRequest represents TL type `addFileToDownloads#33b583b7`.
type AddFileToDownloadsRequest struct {
// Identifier of the file to download
FileID int32
// Chat identifier of the message with the file
ChatID int64
// Message identifier
MessageID int64
// Priority of the download (1-32). The higher the priority, the earlier the file will be
// downloaded. If the priorities of two files are equal, then the last one for which
// downloadFile/addFileToDownloads was called will be downloaded first
Priority int32
}
// AddFileToDownloadsRequestTypeID is TL type id of AddFileToDownloadsRequest.
const AddFileToDownloadsRequestTypeID = 0x33b583b7
// Ensuring interfaces in compile-time for AddFileToDownloadsRequest.
var (
_ bin.Encoder = &AddFileToDownloadsRequest{}
_ bin.Decoder = &AddFileToDownloadsRequest{}
_ bin.BareEncoder = &AddFileToDownloadsRequest{}
_ bin.BareDecoder = &AddFileToDownloadsRequest{}
)
func (a *AddFileToDownloadsRequest) Zero() bool {
if a == nil {
return true
}
if !(a.FileID == 0) {
return false
}
if !(a.ChatID == 0) {
return false
}
if !(a.MessageID == 0) {
return false
}
if !(a.Priority == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (a *AddFileToDownloadsRequest) String() string {
if a == nil {
return "AddFileToDownloadsRequest(nil)"
}
type Alias AddFileToDownloadsRequest
return fmt.Sprintf("AddFileToDownloadsRequest%+v", Alias(*a))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AddFileToDownloadsRequest) TypeID() uint32 {
return AddFileToDownloadsRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*AddFileToDownloadsRequest) TypeName() string {
return "addFileToDownloads"
}
// TypeInfo returns info about TL type.
func (a *AddFileToDownloadsRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "addFileToDownloads",
ID: AddFileToDownloadsRequestTypeID,
}
if a == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "FileID",
SchemaName: "file_id",
},
{
Name: "ChatID",
SchemaName: "chat_id",
},
{
Name: "MessageID",
SchemaName: "message_id",
},
{
Name: "Priority",
SchemaName: "priority",
},
}
return typ
}
// Encode implements bin.Encoder.
func (a *AddFileToDownloadsRequest) Encode(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't encode addFileToDownloads#33b583b7 as nil")
}
b.PutID(AddFileToDownloadsRequestTypeID)
return a.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (a *AddFileToDownloadsRequest) EncodeBare(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't encode addFileToDownloads#33b583b7 as nil")
}
b.PutInt32(a.FileID)
b.PutInt53(a.ChatID)
b.PutInt53(a.MessageID)
b.PutInt32(a.Priority)
return nil
}
// Decode implements bin.Decoder.
func (a *AddFileToDownloadsRequest) Decode(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't decode addFileToDownloads#33b583b7 to nil")
}
if err := b.ConsumeID(AddFileToDownloadsRequestTypeID); err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: %w", err)
}
return a.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (a *AddFileToDownloadsRequest) DecodeBare(b *bin.Buffer) error {
if a == nil {
return fmt.Errorf("can't decode addFileToDownloads#33b583b7 to nil")
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: field file_id: %w", err)
}
a.FileID = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: field chat_id: %w", err)
}
a.ChatID = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: field message_id: %w", err)
}
a.MessageID = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: field priority: %w", err)
}
a.Priority = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (a *AddFileToDownloadsRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if a == nil {
return fmt.Errorf("can't encode addFileToDownloads#33b583b7 as nil")
}
b.ObjStart()
b.PutID("addFileToDownloads")
b.Comma()
b.FieldStart("file_id")
b.PutInt32(a.FileID)
b.Comma()
b.FieldStart("chat_id")
b.PutInt53(a.ChatID)
b.Comma()
b.FieldStart("message_id")
b.PutInt53(a.MessageID)
b.Comma()
b.FieldStart("priority")
b.PutInt32(a.Priority)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (a *AddFileToDownloadsRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if a == nil {
return fmt.Errorf("can't decode addFileToDownloads#33b583b7 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("addFileToDownloads"); err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: %w", err)
}
case "file_id":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: field file_id: %w", err)
}
a.FileID = value
case "chat_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: field chat_id: %w", err)
}
a.ChatID = value
case "message_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: field message_id: %w", err)
}
a.MessageID = value
case "priority":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode addFileToDownloads#33b583b7: field priority: %w", err)
}
a.Priority = value
default:
return b.Skip()
}
return nil
})
}
// GetFileID returns value of FileID field.
func (a *AddFileToDownloadsRequest) GetFileID() (value int32) {
if a == nil {
return
}
return a.FileID
}
// GetChatID returns value of ChatID field.
func (a *AddFileToDownloadsRequest) GetChatID() (value int64) {
if a == nil {
return
}
return a.ChatID
}
// GetMessageID returns value of MessageID field.
func (a *AddFileToDownloadsRequest) GetMessageID() (value int64) {
if a == nil {
return
}
return a.MessageID
}
// GetPriority returns value of Priority field.
func (a *AddFileToDownloadsRequest) GetPriority() (value int32) {
if a == nil {
return
}
return a.Priority
}
// AddFileToDownloads invokes method addFileToDownloads#33b583b7 returning error if any.
func (c *Client) AddFileToDownloads(ctx context.Context, request *AddFileToDownloadsRequest) (*File, error) {
var result File
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}