// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// 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{}
)

// UserStatusEmpty represents TL type `userStatusEmpty#9d05049`.
// User status has not been set yet.
//
// See https://core.telegram.org/constructor/userStatusEmpty for reference.
type UserStatusEmpty struct {
}

// UserStatusEmptyTypeID is TL type id of UserStatusEmpty.
const UserStatusEmptyTypeID = 0x9d05049

// construct implements constructor of UserStatusClass.
func ( UserStatusEmpty) () UserStatusClass { return & }

// Ensuring interfaces in compile-time for UserStatusEmpty.
var (
	_ bin.Encoder     = &UserStatusEmpty{}
	_ bin.Decoder     = &UserStatusEmpty{}
	_ bin.BareEncoder = &UserStatusEmpty{}
	_ bin.BareDecoder = &UserStatusEmpty{}

	_ UserStatusClass = &UserStatusEmpty{}
)

func ( *UserStatusEmpty) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *UserStatusEmpty) () string {
	if  == nil {
		return "UserStatusEmpty(nil)"
	}
	type  UserStatusEmpty
	return fmt.Sprintf("UserStatusEmpty%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*UserStatusEmpty) () uint32 {
	return UserStatusEmptyTypeID
}

// TypeName returns name of type in TL schema.
func (*UserStatusEmpty) () string {
	return "userStatusEmpty"
}

// TypeInfo returns info about TL type.
func ( *UserStatusEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "userStatusEmpty",
		ID:   UserStatusEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *UserStatusEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusEmpty#9d05049 as nil")
	}
	.PutID(UserStatusEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UserStatusEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusEmpty#9d05049 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *UserStatusEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusEmpty#9d05049 to nil")
	}
	if  := .ConsumeID(UserStatusEmptyTypeID);  != nil {
		return fmt.Errorf("unable to decode userStatusEmpty#9d05049: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UserStatusEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusEmpty#9d05049 to nil")
	}
	return nil
}

// UserStatusOnline represents TL type `userStatusOnline#edb93949`.
// Online status of the user.
//
// See https://core.telegram.org/constructor/userStatusOnline for reference.
type UserStatusOnline struct {
	// Time to expiration of the current online status
	Expires int
}

// UserStatusOnlineTypeID is TL type id of UserStatusOnline.
const UserStatusOnlineTypeID = 0xedb93949

// construct implements constructor of UserStatusClass.
func ( UserStatusOnline) () UserStatusClass { return & }

// Ensuring interfaces in compile-time for UserStatusOnline.
var (
	_ bin.Encoder     = &UserStatusOnline{}
	_ bin.Decoder     = &UserStatusOnline{}
	_ bin.BareEncoder = &UserStatusOnline{}
	_ bin.BareDecoder = &UserStatusOnline{}

	_ UserStatusClass = &UserStatusOnline{}
)

func ( *UserStatusOnline) () bool {
	if  == nil {
		return true
	}
	if !(.Expires == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *UserStatusOnline) () string {
	if  == nil {
		return "UserStatusOnline(nil)"
	}
	type  UserStatusOnline
	return fmt.Sprintf("UserStatusOnline%+v", (*))
}

// FillFrom fills UserStatusOnline from given interface.
func ( *UserStatusOnline) ( interface {
	() ( int)
}) {
	.Expires = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*UserStatusOnline) () uint32 {
	return UserStatusOnlineTypeID
}

// TypeName returns name of type in TL schema.
func (*UserStatusOnline) () string {
	return "userStatusOnline"
}

// TypeInfo returns info about TL type.
func ( *UserStatusOnline) () tdp.Type {
	 := tdp.Type{
		Name: "userStatusOnline",
		ID:   UserStatusOnlineTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Expires",
			SchemaName: "expires",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UserStatusOnline) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusOnline#edb93949 as nil")
	}
	.PutID(UserStatusOnlineTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UserStatusOnline) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusOnline#edb93949 as nil")
	}
	.PutInt(.Expires)
	return nil
}

// Decode implements bin.Decoder.
func ( *UserStatusOnline) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusOnline#edb93949 to nil")
	}
	if  := .ConsumeID(UserStatusOnlineTypeID);  != nil {
		return fmt.Errorf("unable to decode userStatusOnline#edb93949: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UserStatusOnline) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusOnline#edb93949 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode userStatusOnline#edb93949: field expires: %w", )
		}
		.Expires = 
	}
	return nil
}

// GetExpires returns value of Expires field.
func ( *UserStatusOnline) () ( int) {
	if  == nil {
		return
	}
	return .Expires
}

// UserStatusOffline represents TL type `userStatusOffline#8c703f`.
// The user's offline status.
//
// See https://core.telegram.org/constructor/userStatusOffline for reference.
type UserStatusOffline struct {
	// Time the user was last seen online
	WasOnline int
}

// UserStatusOfflineTypeID is TL type id of UserStatusOffline.
const UserStatusOfflineTypeID = 0x8c703f

// construct implements constructor of UserStatusClass.
func ( UserStatusOffline) () UserStatusClass { return & }

// Ensuring interfaces in compile-time for UserStatusOffline.
var (
	_ bin.Encoder     = &UserStatusOffline{}
	_ bin.Decoder     = &UserStatusOffline{}
	_ bin.BareEncoder = &UserStatusOffline{}
	_ bin.BareDecoder = &UserStatusOffline{}

	_ UserStatusClass = &UserStatusOffline{}
)

func ( *UserStatusOffline) () bool {
	if  == nil {
		return true
	}
	if !(.WasOnline == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *UserStatusOffline) () string {
	if  == nil {
		return "UserStatusOffline(nil)"
	}
	type  UserStatusOffline
	return fmt.Sprintf("UserStatusOffline%+v", (*))
}

// FillFrom fills UserStatusOffline from given interface.
func ( *UserStatusOffline) ( interface {
	() ( int)
}) {
	.WasOnline = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*UserStatusOffline) () uint32 {
	return UserStatusOfflineTypeID
}

// TypeName returns name of type in TL schema.
func (*UserStatusOffline) () string {
	return "userStatusOffline"
}

// TypeInfo returns info about TL type.
func ( *UserStatusOffline) () tdp.Type {
	 := tdp.Type{
		Name: "userStatusOffline",
		ID:   UserStatusOfflineTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "WasOnline",
			SchemaName: "was_online",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UserStatusOffline) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusOffline#8c703f as nil")
	}
	.PutID(UserStatusOfflineTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UserStatusOffline) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusOffline#8c703f as nil")
	}
	.PutInt(.WasOnline)
	return nil
}

// Decode implements bin.Decoder.
func ( *UserStatusOffline) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusOffline#8c703f to nil")
	}
	if  := .ConsumeID(UserStatusOfflineTypeID);  != nil {
		return fmt.Errorf("unable to decode userStatusOffline#8c703f: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UserStatusOffline) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusOffline#8c703f to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode userStatusOffline#8c703f: field was_online: %w", )
		}
		.WasOnline = 
	}
	return nil
}

// GetWasOnline returns value of WasOnline field.
func ( *UserStatusOffline) () ( int) {
	if  == nil {
		return
	}
	return .WasOnline
}

// UserStatusRecently represents TL type `userStatusRecently#e26f42f1`.
// Online status: last seen recently
//
// See https://core.telegram.org/constructor/userStatusRecently for reference.
type UserStatusRecently struct {
}

// UserStatusRecentlyTypeID is TL type id of UserStatusRecently.
const UserStatusRecentlyTypeID = 0xe26f42f1

// construct implements constructor of UserStatusClass.
func ( UserStatusRecently) () UserStatusClass { return & }

// Ensuring interfaces in compile-time for UserStatusRecently.
var (
	_ bin.Encoder     = &UserStatusRecently{}
	_ bin.Decoder     = &UserStatusRecently{}
	_ bin.BareEncoder = &UserStatusRecently{}
	_ bin.BareDecoder = &UserStatusRecently{}

	_ UserStatusClass = &UserStatusRecently{}
)

func ( *UserStatusRecently) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *UserStatusRecently) () string {
	if  == nil {
		return "UserStatusRecently(nil)"
	}
	type  UserStatusRecently
	return fmt.Sprintf("UserStatusRecently%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*UserStatusRecently) () uint32 {
	return UserStatusRecentlyTypeID
}

// TypeName returns name of type in TL schema.
func (*UserStatusRecently) () string {
	return "userStatusRecently"
}

// TypeInfo returns info about TL type.
func ( *UserStatusRecently) () tdp.Type {
	 := tdp.Type{
		Name: "userStatusRecently",
		ID:   UserStatusRecentlyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *UserStatusRecently) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusRecently#e26f42f1 as nil")
	}
	.PutID(UserStatusRecentlyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UserStatusRecently) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusRecently#e26f42f1 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *UserStatusRecently) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusRecently#e26f42f1 to nil")
	}
	if  := .ConsumeID(UserStatusRecentlyTypeID);  != nil {
		return fmt.Errorf("unable to decode userStatusRecently#e26f42f1: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UserStatusRecently) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusRecently#e26f42f1 to nil")
	}
	return nil
}

// UserStatusLastWeek represents TL type `userStatusLastWeek#7bf09fc`.
// Online status: last seen last week
//
// See https://core.telegram.org/constructor/userStatusLastWeek for reference.
type UserStatusLastWeek struct {
}

// UserStatusLastWeekTypeID is TL type id of UserStatusLastWeek.
const UserStatusLastWeekTypeID = 0x7bf09fc

// construct implements constructor of UserStatusClass.
func ( UserStatusLastWeek) () UserStatusClass { return & }

// Ensuring interfaces in compile-time for UserStatusLastWeek.
var (
	_ bin.Encoder     = &UserStatusLastWeek{}
	_ bin.Decoder     = &UserStatusLastWeek{}
	_ bin.BareEncoder = &UserStatusLastWeek{}
	_ bin.BareDecoder = &UserStatusLastWeek{}

	_ UserStatusClass = &UserStatusLastWeek{}
)

func ( *UserStatusLastWeek) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *UserStatusLastWeek) () string {
	if  == nil {
		return "UserStatusLastWeek(nil)"
	}
	type  UserStatusLastWeek
	return fmt.Sprintf("UserStatusLastWeek%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*UserStatusLastWeek) () uint32 {
	return UserStatusLastWeekTypeID
}

// TypeName returns name of type in TL schema.
func (*UserStatusLastWeek) () string {
	return "userStatusLastWeek"
}

// TypeInfo returns info about TL type.
func ( *UserStatusLastWeek) () tdp.Type {
	 := tdp.Type{
		Name: "userStatusLastWeek",
		ID:   UserStatusLastWeekTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *UserStatusLastWeek) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusLastWeek#7bf09fc as nil")
	}
	.PutID(UserStatusLastWeekTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UserStatusLastWeek) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusLastWeek#7bf09fc as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *UserStatusLastWeek) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusLastWeek#7bf09fc to nil")
	}
	if  := .ConsumeID(UserStatusLastWeekTypeID);  != nil {
		return fmt.Errorf("unable to decode userStatusLastWeek#7bf09fc: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UserStatusLastWeek) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusLastWeek#7bf09fc to nil")
	}
	return nil
}

// UserStatusLastMonth represents TL type `userStatusLastMonth#77ebc742`.
// Online status: last seen last month
//
// See https://core.telegram.org/constructor/userStatusLastMonth for reference.
type UserStatusLastMonth struct {
}

// UserStatusLastMonthTypeID is TL type id of UserStatusLastMonth.
const UserStatusLastMonthTypeID = 0x77ebc742

// construct implements constructor of UserStatusClass.
func ( UserStatusLastMonth) () UserStatusClass { return & }

// Ensuring interfaces in compile-time for UserStatusLastMonth.
var (
	_ bin.Encoder     = &UserStatusLastMonth{}
	_ bin.Decoder     = &UserStatusLastMonth{}
	_ bin.BareEncoder = &UserStatusLastMonth{}
	_ bin.BareDecoder = &UserStatusLastMonth{}

	_ UserStatusClass = &UserStatusLastMonth{}
)

func ( *UserStatusLastMonth) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *UserStatusLastMonth) () string {
	if  == nil {
		return "UserStatusLastMonth(nil)"
	}
	type  UserStatusLastMonth
	return fmt.Sprintf("UserStatusLastMonth%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*UserStatusLastMonth) () uint32 {
	return UserStatusLastMonthTypeID
}

// TypeName returns name of type in TL schema.
func (*UserStatusLastMonth) () string {
	return "userStatusLastMonth"
}

// TypeInfo returns info about TL type.
func ( *UserStatusLastMonth) () tdp.Type {
	 := tdp.Type{
		Name: "userStatusLastMonth",
		ID:   UserStatusLastMonthTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *UserStatusLastMonth) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusLastMonth#77ebc742 as nil")
	}
	.PutID(UserStatusLastMonthTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UserStatusLastMonth) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode userStatusLastMonth#77ebc742 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *UserStatusLastMonth) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusLastMonth#77ebc742 to nil")
	}
	if  := .ConsumeID(UserStatusLastMonthTypeID);  != nil {
		return fmt.Errorf("unable to decode userStatusLastMonth#77ebc742: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UserStatusLastMonth) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode userStatusLastMonth#77ebc742 to nil")
	}
	return nil
}

// UserStatusClassName is schema name of UserStatusClass.
const UserStatusClassName = "UserStatus"

// UserStatusClass represents UserStatus generic type.
//
// See https://core.telegram.org/type/UserStatus for reference.
//
// Example:
//
//	g, err := tg.DecodeUserStatus(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.UserStatusEmpty: // userStatusEmpty#9d05049
//	case *tg.UserStatusOnline: // userStatusOnline#edb93949
//	case *tg.UserStatusOffline: // userStatusOffline#8c703f
//	case *tg.UserStatusRecently: // userStatusRecently#e26f42f1
//	case *tg.UserStatusLastWeek: // userStatusLastWeek#7bf09fc
//	case *tg.UserStatusLastMonth: // userStatusLastMonth#77ebc742
//	default: panic(v)
//	}
type UserStatusClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() UserStatusClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeUserStatus implements binary de-serialization for UserStatusClass.
func ( *bin.Buffer) (UserStatusClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case UserStatusEmptyTypeID:
		// Decoding userStatusEmpty#9d05049.
		 := UserStatusEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UserStatusClass: %w", )
		}
		return &, nil
	case UserStatusOnlineTypeID:
		// Decoding userStatusOnline#edb93949.
		 := UserStatusOnline{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UserStatusClass: %w", )
		}
		return &, nil
	case UserStatusOfflineTypeID:
		// Decoding userStatusOffline#8c703f.
		 := UserStatusOffline{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UserStatusClass: %w", )
		}
		return &, nil
	case UserStatusRecentlyTypeID:
		// Decoding userStatusRecently#e26f42f1.
		 := UserStatusRecently{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UserStatusClass: %w", )
		}
		return &, nil
	case UserStatusLastWeekTypeID:
		// Decoding userStatusLastWeek#7bf09fc.
		 := UserStatusLastWeek{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UserStatusClass: %w", )
		}
		return &, nil
	case UserStatusLastMonthTypeID:
		// Decoding userStatusLastMonth#77ebc742.
		 := UserStatusLastMonth{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UserStatusClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode UserStatusClass: %w", bin.NewUnexpectedID())
	}
}

// UserStatus boxes the UserStatusClass providing a helper.
type UserStatusBox struct {
	UserStatus UserStatusClass
}

// Decode implements bin.Decoder for UserStatusBox.
func ( *UserStatusBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode UserStatusBox to nil")
	}
	,  := DecodeUserStatus()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.UserStatus = 
	return nil
}

// Encode implements bin.Encode for UserStatusBox.
func ( *UserStatusBox) ( *bin.Buffer) error {
	if  == nil || .UserStatus == nil {
		return fmt.Errorf("unable to encode UserStatusClass as nil")
	}
	return .UserStatus.Encode()
}