Files
mautrix-telegram/pkg/gotd/tdapi/tl_time_zone_gen.go
T
2025-06-27 20:03:37 -07:00

262 lines
5.3 KiB
Go

// 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{}
)
// TimeZone represents TL type `timeZone#b919f2dd`.
type TimeZone struct {
// Unique time zone identifier
ID string
// Time zone name
Name string
// Current UTC time offset for the time zone
UtcTimeOffset int32
}
// TimeZoneTypeID is TL type id of TimeZone.
const TimeZoneTypeID = 0xb919f2dd
// Ensuring interfaces in compile-time for TimeZone.
var (
_ bin.Encoder = &TimeZone{}
_ bin.Decoder = &TimeZone{}
_ bin.BareEncoder = &TimeZone{}
_ bin.BareDecoder = &TimeZone{}
)
func (t *TimeZone) Zero() bool {
if t == nil {
return true
}
if !(t.ID == "") {
return false
}
if !(t.Name == "") {
return false
}
if !(t.UtcTimeOffset == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (t *TimeZone) String() string {
if t == nil {
return "TimeZone(nil)"
}
type Alias TimeZone
return fmt.Sprintf("TimeZone%+v", Alias(*t))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*TimeZone) TypeID() uint32 {
return TimeZoneTypeID
}
// TypeName returns name of type in TL schema.
func (*TimeZone) TypeName() string {
return "timeZone"
}
// TypeInfo returns info about TL type.
func (t *TimeZone) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "timeZone",
ID: TimeZoneTypeID,
}
if t == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
{
Name: "Name",
SchemaName: "name",
},
{
Name: "UtcTimeOffset",
SchemaName: "utc_time_offset",
},
}
return typ
}
// Encode implements bin.Encoder.
func (t *TimeZone) Encode(b *bin.Buffer) error {
if t == nil {
return fmt.Errorf("can't encode timeZone#b919f2dd as nil")
}
b.PutID(TimeZoneTypeID)
return t.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (t *TimeZone) EncodeBare(b *bin.Buffer) error {
if t == nil {
return fmt.Errorf("can't encode timeZone#b919f2dd as nil")
}
b.PutString(t.ID)
b.PutString(t.Name)
b.PutInt32(t.UtcTimeOffset)
return nil
}
// Decode implements bin.Decoder.
func (t *TimeZone) Decode(b *bin.Buffer) error {
if t == nil {
return fmt.Errorf("can't decode timeZone#b919f2dd to nil")
}
if err := b.ConsumeID(TimeZoneTypeID); err != nil {
return fmt.Errorf("unable to decode timeZone#b919f2dd: %w", err)
}
return t.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (t *TimeZone) DecodeBare(b *bin.Buffer) error {
if t == nil {
return fmt.Errorf("can't decode timeZone#b919f2dd to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode timeZone#b919f2dd: field id: %w", err)
}
t.ID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode timeZone#b919f2dd: field name: %w", err)
}
t.Name = value
}
{
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode timeZone#b919f2dd: field utc_time_offset: %w", err)
}
t.UtcTimeOffset = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (t *TimeZone) EncodeTDLibJSON(b tdjson.Encoder) error {
if t == nil {
return fmt.Errorf("can't encode timeZone#b919f2dd as nil")
}
b.ObjStart()
b.PutID("timeZone")
b.Comma()
b.FieldStart("id")
b.PutString(t.ID)
b.Comma()
b.FieldStart("name")
b.PutString(t.Name)
b.Comma()
b.FieldStart("utc_time_offset")
b.PutInt32(t.UtcTimeOffset)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (t *TimeZone) DecodeTDLibJSON(b tdjson.Decoder) error {
if t == nil {
return fmt.Errorf("can't decode timeZone#b919f2dd to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("timeZone"); err != nil {
return fmt.Errorf("unable to decode timeZone#b919f2dd: %w", err)
}
case "id":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode timeZone#b919f2dd: field id: %w", err)
}
t.ID = value
case "name":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode timeZone#b919f2dd: field name: %w", err)
}
t.Name = value
case "utc_time_offset":
value, err := b.Int32()
if err != nil {
return fmt.Errorf("unable to decode timeZone#b919f2dd: field utc_time_offset: %w", err)
}
t.UtcTimeOffset = value
default:
return b.Skip()
}
return nil
})
}
// GetID returns value of ID field.
func (t *TimeZone) GetID() (value string) {
if t == nil {
return
}
return t.ID
}
// GetName returns value of Name field.
func (t *TimeZone) GetName() (value string) {
if t == nil {
return
}
return t.Name
}
// GetUtcTimeOffset returns value of UtcTimeOffset field.
func (t *TimeZone) GetUtcTimeOffset() (value int32) {
if t == nil {
return
}
return t.UtcTimeOffset
}