// 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{} ) // StarCount represents TL type `starCount#a2a2b4f8`. type StarCount struct { // Number of Telegram Stars StarCount int64 } // StarCountTypeID is TL type id of StarCount. const StarCountTypeID = 0xa2a2b4f8 // Ensuring interfaces in compile-time for StarCount. var ( _ bin.Encoder = &StarCount{} _ bin.Decoder = &StarCount{} _ bin.BareEncoder = &StarCount{} _ bin.BareDecoder = &StarCount{} ) func (s *StarCount) Zero() bool { if s == nil { return true } if !(s.StarCount == 0) { return false } return true } // String implements fmt.Stringer. func (s *StarCount) String() string { if s == nil { return "StarCount(nil)" } type Alias StarCount return fmt.Sprintf("StarCount%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*StarCount) TypeID() uint32 { return StarCountTypeID } // TypeName returns name of type in TL schema. func (*StarCount) TypeName() string { return "starCount" } // TypeInfo returns info about TL type. func (s *StarCount) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "starCount", ID: StarCountTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "StarCount", SchemaName: "star_count", }, } return typ } // Encode implements bin.Encoder. func (s *StarCount) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode starCount#a2a2b4f8 as nil") } b.PutID(StarCountTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *StarCount) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode starCount#a2a2b4f8 as nil") } b.PutInt53(s.StarCount) return nil } // Decode implements bin.Decoder. func (s *StarCount) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode starCount#a2a2b4f8 to nil") } if err := b.ConsumeID(StarCountTypeID); err != nil { return fmt.Errorf("unable to decode starCount#a2a2b4f8: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *StarCount) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode starCount#a2a2b4f8 to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode starCount#a2a2b4f8: field star_count: %w", err) } s.StarCount = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *StarCount) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { return fmt.Errorf("can't encode starCount#a2a2b4f8 as nil") } b.ObjStart() b.PutID("starCount") b.Comma() b.FieldStart("star_count") b.PutInt53(s.StarCount) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *StarCount) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { return fmt.Errorf("can't decode starCount#a2a2b4f8 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("starCount"); err != nil { return fmt.Errorf("unable to decode starCount#a2a2b4f8: %w", err) } case "star_count": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode starCount#a2a2b4f8: field star_count: %w", err) } s.StarCount = value default: return b.Skip() } return nil }) } // GetStarCount returns value of StarCount field. func (s *StarCount) GetStarCount() (value int64) { if s == nil { return } return s.StarCount }