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

334 lines
7.7 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{}
)
// RemoteFile represents TL type `remoteFile#2c917856`.
type RemoteFile struct {
// Remote file identifier; may be empty. Can be used by the current user across
// application restarts or even from other devices. Uniquely identifies a file, but a
// file can have a lot of different valid identifiers.
ID string
// Unique file identifier; may be empty if unknown. The unique file identifier which is
// the same for the same file even for different users and is persistent over time
UniqueID string
// True, if the file is currently being uploaded (or a remote copy is being generated by
// some other means)
IsUploadingActive bool
// True, if a remote copy is fully available
IsUploadingCompleted bool
// Size of the remote available part of the file, in bytes; 0 if unknown
UploadedSize int64
}
// RemoteFileTypeID is TL type id of RemoteFile.
const RemoteFileTypeID = 0x2c917856
// Ensuring interfaces in compile-time for RemoteFile.
var (
_ bin.Encoder = &RemoteFile{}
_ bin.Decoder = &RemoteFile{}
_ bin.BareEncoder = &RemoteFile{}
_ bin.BareDecoder = &RemoteFile{}
)
func (r *RemoteFile) Zero() bool {
if r == nil {
return true
}
if !(r.ID == "") {
return false
}
if !(r.UniqueID == "") {
return false
}
if !(r.IsUploadingActive == false) {
return false
}
if !(r.IsUploadingCompleted == false) {
return false
}
if !(r.UploadedSize == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (r *RemoteFile) String() string {
if r == nil {
return "RemoteFile(nil)"
}
type Alias RemoteFile
return fmt.Sprintf("RemoteFile%+v", Alias(*r))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*RemoteFile) TypeID() uint32 {
return RemoteFileTypeID
}
// TypeName returns name of type in TL schema.
func (*RemoteFile) TypeName() string {
return "remoteFile"
}
// TypeInfo returns info about TL type.
func (r *RemoteFile) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "remoteFile",
ID: RemoteFileTypeID,
}
if r == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
{
Name: "UniqueID",
SchemaName: "unique_id",
},
{
Name: "IsUploadingActive",
SchemaName: "is_uploading_active",
},
{
Name: "IsUploadingCompleted",
SchemaName: "is_uploading_completed",
},
{
Name: "UploadedSize",
SchemaName: "uploaded_size",
},
}
return typ
}
// Encode implements bin.Encoder.
func (r *RemoteFile) Encode(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't encode remoteFile#2c917856 as nil")
}
b.PutID(RemoteFileTypeID)
return r.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (r *RemoteFile) EncodeBare(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't encode remoteFile#2c917856 as nil")
}
b.PutString(r.ID)
b.PutString(r.UniqueID)
b.PutBool(r.IsUploadingActive)
b.PutBool(r.IsUploadingCompleted)
b.PutInt53(r.UploadedSize)
return nil
}
// Decode implements bin.Decoder.
func (r *RemoteFile) Decode(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't decode remoteFile#2c917856 to nil")
}
if err := b.ConsumeID(RemoteFileTypeID); err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: %w", err)
}
return r.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (r *RemoteFile) DecodeBare(b *bin.Buffer) error {
if r == nil {
return fmt.Errorf("can't decode remoteFile#2c917856 to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field id: %w", err)
}
r.ID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field unique_id: %w", err)
}
r.UniqueID = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field is_uploading_active: %w", err)
}
r.IsUploadingActive = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field is_uploading_completed: %w", err)
}
r.IsUploadingCompleted = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field uploaded_size: %w", err)
}
r.UploadedSize = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (r *RemoteFile) EncodeTDLibJSON(b tdjson.Encoder) error {
if r == nil {
return fmt.Errorf("can't encode remoteFile#2c917856 as nil")
}
b.ObjStart()
b.PutID("remoteFile")
b.Comma()
b.FieldStart("id")
b.PutString(r.ID)
b.Comma()
b.FieldStart("unique_id")
b.PutString(r.UniqueID)
b.Comma()
b.FieldStart("is_uploading_active")
b.PutBool(r.IsUploadingActive)
b.Comma()
b.FieldStart("is_uploading_completed")
b.PutBool(r.IsUploadingCompleted)
b.Comma()
b.FieldStart("uploaded_size")
b.PutInt53(r.UploadedSize)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (r *RemoteFile) DecodeTDLibJSON(b tdjson.Decoder) error {
if r == nil {
return fmt.Errorf("can't decode remoteFile#2c917856 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("remoteFile"); err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: %w", err)
}
case "id":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field id: %w", err)
}
r.ID = value
case "unique_id":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field unique_id: %w", err)
}
r.UniqueID = value
case "is_uploading_active":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field is_uploading_active: %w", err)
}
r.IsUploadingActive = value
case "is_uploading_completed":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field is_uploading_completed: %w", err)
}
r.IsUploadingCompleted = value
case "uploaded_size":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode remoteFile#2c917856: field uploaded_size: %w", err)
}
r.UploadedSize = value
default:
return b.Skip()
}
return nil
})
}
// GetID returns value of ID field.
func (r *RemoteFile) GetID() (value string) {
if r == nil {
return
}
return r.ID
}
// GetUniqueID returns value of UniqueID field.
func (r *RemoteFile) GetUniqueID() (value string) {
if r == nil {
return
}
return r.UniqueID
}
// GetIsUploadingActive returns value of IsUploadingActive field.
func (r *RemoteFile) GetIsUploadingActive() (value bool) {
if r == nil {
return
}
return r.IsUploadingActive
}
// GetIsUploadingCompleted returns value of IsUploadingCompleted field.
func (r *RemoteFile) GetIsUploadingCompleted() (value bool) {
if r == nil {
return
}
return r.IsUploadingCompleted
}
// GetUploadedSize returns value of UploadedSize field.
func (r *RemoteFile) GetUploadedSize() (value int64) {
if r == nil {
return
}
return r.UploadedSize
}