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 PeerColor struct {
Flags bin .Fields
Color int
BackgroundEmojiID int64
}
const PeerColorTypeID = 0xb54b5acf
var (
_ bin .Encoder = &PeerColor {}
_ bin .Decoder = &PeerColor {}
_ bin .BareEncoder = &PeerColor {}
_ bin .BareDecoder = &PeerColor {}
)
func (p *PeerColor ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Color == 0 ) {
return false
}
if !(p .BackgroundEmojiID == 0 ) {
return false
}
return true
}
func (p *PeerColor ) String () string {
if p == nil {
return "PeerColor(nil)"
}
type Alias PeerColor
return fmt .Sprintf ("PeerColor%+v" , Alias (*p ))
}
func (p *PeerColor ) FillFrom (from interface {
GetColor () (value int , ok bool )
GetBackgroundEmojiID () (value int64 , ok bool )
}) {
if val , ok := from .GetColor (); ok {
p .Color = val
}
if val , ok := from .GetBackgroundEmojiID (); ok {
p .BackgroundEmojiID = val
}
}
func (*PeerColor ) TypeID () uint32 {
return PeerColorTypeID
}
func (*PeerColor ) TypeName () string {
return "peerColor"
}
func (p *PeerColor ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "peerColor" ,
ID : PeerColorTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Color" ,
SchemaName : "color" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "BackgroundEmojiID" ,
SchemaName : "background_emoji_id" ,
Null : !p .Flags .Has (1 ),
},
}
return typ
}
func (p *PeerColor ) SetFlags () {
if !(p .Color == 0 ) {
p .Flags .Set (0 )
}
if !(p .BackgroundEmojiID == 0 ) {
p .Flags .Set (1 )
}
}
func (p *PeerColor ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerColor#b54b5acf as nil" )
}
b .PutID (PeerColorTypeID )
return p .EncodeBare (b )
}
func (p *PeerColor ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerColor#b54b5acf as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode peerColor#b54b5acf: field flags: %w" , err )
}
if p .Flags .Has (0 ) {
b .PutInt (p .Color )
}
if p .Flags .Has (1 ) {
b .PutLong (p .BackgroundEmojiID )
}
return nil
}
func (p *PeerColor ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerColor#b54b5acf to nil" )
}
if err := b .ConsumeID (PeerColorTypeID ); err != nil {
return fmt .Errorf ("unable to decode peerColor#b54b5acf: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PeerColor ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerColor#b54b5acf to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode peerColor#b54b5acf: field flags: %w" , err )
}
}
if p .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerColor#b54b5acf: field color: %w" , err )
}
p .Color = value
}
if p .Flags .Has (1 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode peerColor#b54b5acf: field background_emoji_id: %w" , err )
}
p .BackgroundEmojiID = value
}
return nil
}
func (p *PeerColor ) SetColor (value int ) {
p .Flags .Set (0 )
p .Color = value
}
func (p *PeerColor ) GetColor () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (0 ) {
return value , false
}
return p .Color , true
}
func (p *PeerColor ) SetBackgroundEmojiID (value int64 ) {
p .Flags .Set (1 )
p .BackgroundEmojiID = value
}
func (p *PeerColor ) GetBackgroundEmojiID () (value int64 , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (1 ) {
return value , false
}
return p .BackgroundEmojiID , true
}
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 .