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 TodoItem struct {
ID int
Title TextWithEntities
}
const TodoItemTypeID = 0xcba9a52f
var (
_ bin .Encoder = &TodoItem {}
_ bin .Decoder = &TodoItem {}
_ bin .BareEncoder = &TodoItem {}
_ bin .BareDecoder = &TodoItem {}
)
func (t *TodoItem ) Zero () bool {
if t == nil {
return true
}
if !(t .ID == 0 ) {
return false
}
if !(t .Title .Zero ()) {
return false
}
return true
}
func (t *TodoItem ) String () string {
if t == nil {
return "TodoItem(nil)"
}
type Alias TodoItem
return fmt .Sprintf ("TodoItem%+v" , Alias (*t ))
}
func (t *TodoItem ) FillFrom (from interface {
GetID () (value int )
GetTitle () (value TextWithEntities )
}) {
t .ID = from .GetID ()
t .Title = from .GetTitle ()
}
func (*TodoItem ) TypeID () uint32 {
return TodoItemTypeID
}
func (*TodoItem ) TypeName () string {
return "todoItem"
}
func (t *TodoItem ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "todoItem" ,
ID : TodoItemTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
}
return typ
}
func (t *TodoItem ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode todoItem#cba9a52f as nil" )
}
b .PutID (TodoItemTypeID )
return t .EncodeBare (b )
}
func (t *TodoItem ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode todoItem#cba9a52f as nil" )
}
b .PutInt (t .ID )
if err := t .Title .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode todoItem#cba9a52f: field title: %w" , err )
}
return nil
}
func (t *TodoItem ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode todoItem#cba9a52f to nil" )
}
if err := b .ConsumeID (TodoItemTypeID ); err != nil {
return fmt .Errorf ("unable to decode todoItem#cba9a52f: %w" , err )
}
return t .DecodeBare (b )
}
func (t *TodoItem ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode todoItem#cba9a52f to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode todoItem#cba9a52f: field id: %w" , err )
}
t .ID = value
}
{
if err := t .Title .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode todoItem#cba9a52f: field title: %w" , err )
}
}
return nil
}
func (t *TodoItem ) GetID () (value int ) {
if t == nil {
return
}
return t .ID
}
func (t *TodoItem ) GetTitle () (value TextWithEntities ) {
if t == nil {
return
}
return t .Title
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .