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 MessagesGetDocumentByHashRequest struct {
SHA256 []byte
Size int64
MimeType string
}
const MessagesGetDocumentByHashRequestTypeID = 0xb1f2061f
var (
_ bin .Encoder = &MessagesGetDocumentByHashRequest {}
_ bin .Decoder = &MessagesGetDocumentByHashRequest {}
_ bin .BareEncoder = &MessagesGetDocumentByHashRequest {}
_ bin .BareDecoder = &MessagesGetDocumentByHashRequest {}
)
func (g *MessagesGetDocumentByHashRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .SHA256 == nil ) {
return false
}
if !(g .Size == 0 ) {
return false
}
if !(g .MimeType == "" ) {
return false
}
return true
}
func (g *MessagesGetDocumentByHashRequest ) String () string {
if g == nil {
return "MessagesGetDocumentByHashRequest(nil)"
}
type Alias MessagesGetDocumentByHashRequest
return fmt .Sprintf ("MessagesGetDocumentByHashRequest%+v" , Alias (*g ))
}
func (g *MessagesGetDocumentByHashRequest ) FillFrom (from interface {
GetSHA256 () (value []byte )
GetSize () (value int64 )
GetMimeType () (value string )
}) {
g .SHA256 = from .GetSHA256 ()
g .Size = from .GetSize ()
g .MimeType = from .GetMimeType ()
}
func (*MessagesGetDocumentByHashRequest ) TypeID () uint32 {
return MessagesGetDocumentByHashRequestTypeID
}
func (*MessagesGetDocumentByHashRequest ) TypeName () string {
return "messages.getDocumentByHash"
}
func (g *MessagesGetDocumentByHashRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.getDocumentByHash" ,
ID : MessagesGetDocumentByHashRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "SHA256" ,
SchemaName : "sha256" ,
},
{
Name : "Size" ,
SchemaName : "size" ,
},
{
Name : "MimeType" ,
SchemaName : "mime_type" ,
},
}
return typ
}
func (g *MessagesGetDocumentByHashRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getDocumentByHash#b1f2061f as nil" )
}
b .PutID (MessagesGetDocumentByHashRequestTypeID )
return g .EncodeBare (b )
}
func (g *MessagesGetDocumentByHashRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getDocumentByHash#b1f2061f as nil" )
}
b .PutBytes (g .SHA256 )
b .PutLong (g .Size )
b .PutString (g .MimeType )
return nil
}
func (g *MessagesGetDocumentByHashRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getDocumentByHash#b1f2061f to nil" )
}
if err := b .ConsumeID (MessagesGetDocumentByHashRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.getDocumentByHash#b1f2061f: %w" , err )
}
return g .DecodeBare (b )
}
func (g *MessagesGetDocumentByHashRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getDocumentByHash#b1f2061f to nil" )
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getDocumentByHash#b1f2061f: field sha256: %w" , err )
}
g .SHA256 = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getDocumentByHash#b1f2061f: field size: %w" , err )
}
g .Size = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getDocumentByHash#b1f2061f: field mime_type: %w" , err )
}
g .MimeType = value
}
return nil
}
func (g *MessagesGetDocumentByHashRequest ) GetSHA256 () (value []byte ) {
if g == nil {
return
}
return g .SHA256
}
func (g *MessagesGetDocumentByHashRequest ) GetSize () (value int64 ) {
if g == nil {
return
}
return g .Size
}
func (g *MessagesGetDocumentByHashRequest ) GetMimeType () (value string ) {
if g == nil {
return
}
return g .MimeType
}
func (c *Client ) MessagesGetDocumentByHash (ctx context .Context , request *MessagesGetDocumentByHashRequest ) (DocumentClass , error ) {
var result DocumentBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Document , nil
}
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 .