package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type InputWebDocument struct {
URL string
Size int
MimeType string
Attributes []DocumentAttributeClass
}
const InputWebDocumentTypeID = 0x9bed434d
var (
_ bin .Encoder = &InputWebDocument {}
_ bin .Decoder = &InputWebDocument {}
_ bin .BareEncoder = &InputWebDocument {}
_ bin .BareDecoder = &InputWebDocument {}
)
func (i *InputWebDocument ) Zero () bool {
if i == nil {
return true
}
if !(i .URL == "" ) {
return false
}
if !(i .Size == 0 ) {
return false
}
if !(i .MimeType == "" ) {
return false
}
if !(i .Attributes == nil ) {
return false
}
return true
}
func (i *InputWebDocument ) String () string {
if i == nil {
return "InputWebDocument(nil)"
}
type Alias InputWebDocument
return fmt .Sprintf ("InputWebDocument%+v" , Alias (*i ))
}
func (i *InputWebDocument ) FillFrom (from interface {
GetURL () (value string )
GetSize () (value int )
GetMimeType () (value string )
GetAttributes () (value []DocumentAttributeClass )
}) {
i .URL = from .GetURL ()
i .Size = from .GetSize ()
i .MimeType = from .GetMimeType ()
i .Attributes = from .GetAttributes ()
}
func (*InputWebDocument ) TypeID () uint32 {
return InputWebDocumentTypeID
}
func (*InputWebDocument ) TypeName () string {
return "inputWebDocument"
}
func (i *InputWebDocument ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputWebDocument" ,
ID : InputWebDocumentTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "URL" ,
SchemaName : "url" ,
},
{
Name : "Size" ,
SchemaName : "size" ,
},
{
Name : "MimeType" ,
SchemaName : "mime_type" ,
},
{
Name : "Attributes" ,
SchemaName : "attributes" ,
},
}
return typ
}
func (i *InputWebDocument ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputWebDocument#9bed434d as nil" )
}
b .PutID (InputWebDocumentTypeID )
return i .EncodeBare (b )
}
func (i *InputWebDocument ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputWebDocument#9bed434d as nil" )
}
b .PutString (i .URL )
b .PutInt (i .Size )
b .PutString (i .MimeType )
b .PutVectorHeader (len (i .Attributes ))
for idx , v := range i .Attributes {
if v == nil {
return fmt .Errorf ("unable to encode inputWebDocument#9bed434d: field attributes element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputWebDocument#9bed434d: field attributes element with index %d: %w" , idx , err )
}
}
return nil
}
func (i *InputWebDocument ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputWebDocument#9bed434d to nil" )
}
if err := b .ConsumeID (InputWebDocumentTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputWebDocument#9bed434d: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputWebDocument ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputWebDocument#9bed434d to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebDocument#9bed434d: field url: %w" , err )
}
i .URL = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebDocument#9bed434d: field size: %w" , err )
}
i .Size = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebDocument#9bed434d: field mime_type: %w" , err )
}
i .MimeType = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebDocument#9bed434d: field attributes: %w" , err )
}
if headerLen > 0 {
i .Attributes = make ([]DocumentAttributeClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeDocumentAttribute (b )
if err != nil {
return fmt .Errorf ("unable to decode inputWebDocument#9bed434d: field attributes: %w" , err )
}
i .Attributes = append (i .Attributes , value )
}
}
return nil
}
func (i *InputWebDocument ) GetURL () (value string ) {
if i == nil {
return
}
return i .URL
}
func (i *InputWebDocument ) GetSize () (value int ) {
if i == nil {
return
}
return i .Size
}
func (i *InputWebDocument ) GetMimeType () (value string ) {
if i == nil {
return
}
return i .MimeType
}
func (i *InputWebDocument ) GetAttributes () (value []DocumentAttributeClass ) {
if i == nil {
return
}
return i .Attributes
}
func (i *InputWebDocument ) MapAttributes () (value DocumentAttributeClassArray ) {
return DocumentAttributeClassArray (i .Attributes )
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .