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

// ChatParticipant represents TL type `chatParticipant#c02d4007`.
// Group member.
//
// See https://core.telegram.org/constructor/chatParticipant for reference.
type ChatParticipant struct {
	// Member user ID
	UserID int64
	// ID of the user that added the member to the group
	InviterID int64
	// Date added to the group
	Date int
}

// ChatParticipantTypeID is TL type id of ChatParticipant.
const ChatParticipantTypeID = 0xc02d4007

// construct implements constructor of ChatParticipantClass.
func ( ChatParticipant) () ChatParticipantClass { return & }

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

	_ ChatParticipantClass = &ChatParticipant{}
)

func ( *ChatParticipant) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.InviterID == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChatParticipant from given interface.
func ( *ChatParticipant) ( interface {
	() ( int64)
	() ( int64)
	() ( int)
}) {
	.UserID = .()
	.InviterID = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatParticipant) () tdp.Type {
	 := tdp.Type{
		Name: "chatParticipant",
		ID:   ChatParticipantTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "InviterID",
			SchemaName: "inviter_id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatParticipant) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatParticipant#c02d4007 as nil")
	}
	.PutID(ChatParticipantTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatParticipant) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatParticipant#c02d4007 as nil")
	}
	.PutLong(.UserID)
	.PutLong(.InviterID)
	.PutInt(.Date)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatParticipant) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatParticipant#c02d4007 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatParticipant#c02d4007: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatParticipant#c02d4007: field inviter_id: %w", )
		}
		.InviterID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode chatParticipant#c02d4007: field date: %w", )
		}
		.Date = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *ChatParticipant) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// GetInviterID returns value of InviterID field.
func ( *ChatParticipant) () ( int64) {
	if  == nil {
		return
	}
	return .InviterID
}

// GetDate returns value of Date field.
func ( *ChatParticipant) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// ChatParticipantCreator represents TL type `chatParticipantCreator#e46bcee4`.
// Represents the creator of the group
//
// See https://core.telegram.org/constructor/chatParticipantCreator for reference.
type ChatParticipantCreator struct {
	// ID of the user that created the group
	UserID int64
}

// ChatParticipantCreatorTypeID is TL type id of ChatParticipantCreator.
const ChatParticipantCreatorTypeID = 0xe46bcee4

// construct implements constructor of ChatParticipantClass.
func ( ChatParticipantCreator) () ChatParticipantClass { return & }

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

	_ ChatParticipantClass = &ChatParticipantCreator{}
)

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

	return true
}

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

// FillFrom fills ChatParticipantCreator from given interface.
func ( *ChatParticipantCreator) ( interface {
	() ( int64)
}) {
	.UserID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatParticipantCreator) () tdp.Type {
	 := tdp.Type{
		Name: "chatParticipantCreator",
		ID:   ChatParticipantCreatorTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatParticipantCreator) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatParticipantCreator#e46bcee4 as nil")
	}
	.PutID(ChatParticipantCreatorTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatParticipantCreator) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatParticipantCreator#e46bcee4 as nil")
	}
	.PutLong(.UserID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatParticipantCreator) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatParticipantCreator#e46bcee4 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatParticipantCreator#e46bcee4: field user_id: %w", )
		}
		.UserID = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *ChatParticipantCreator) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// ChatParticipantAdmin represents TL type `chatParticipantAdmin#a0933f5b`.
// Chat admin
//
// See https://core.telegram.org/constructor/chatParticipantAdmin for reference.
type ChatParticipantAdmin struct {
	// ID of a group member that is admin
	UserID int64
	// ID of the user that added the member to the group
	InviterID int64
	// Date when the user was added
	Date int
}

// ChatParticipantAdminTypeID is TL type id of ChatParticipantAdmin.
const ChatParticipantAdminTypeID = 0xa0933f5b

// construct implements constructor of ChatParticipantClass.
func ( ChatParticipantAdmin) () ChatParticipantClass { return & }

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

	_ ChatParticipantClass = &ChatParticipantAdmin{}
)

func ( *ChatParticipantAdmin) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.InviterID == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChatParticipantAdmin from given interface.
func ( *ChatParticipantAdmin) ( interface {
	() ( int64)
	() ( int64)
	() ( int)
}) {
	.UserID = .()
	.InviterID = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatParticipantAdmin) () tdp.Type {
	 := tdp.Type{
		Name: "chatParticipantAdmin",
		ID:   ChatParticipantAdminTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "InviterID",
			SchemaName: "inviter_id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatParticipantAdmin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatParticipantAdmin#a0933f5b as nil")
	}
	.PutID(ChatParticipantAdminTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatParticipantAdmin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatParticipantAdmin#a0933f5b as nil")
	}
	.PutLong(.UserID)
	.PutLong(.InviterID)
	.PutInt(.Date)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatParticipantAdmin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatParticipantAdmin#a0933f5b to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatParticipantAdmin#a0933f5b: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatParticipantAdmin#a0933f5b: field inviter_id: %w", )
		}
		.InviterID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode chatParticipantAdmin#a0933f5b: field date: %w", )
		}
		.Date = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *ChatParticipantAdmin) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// GetInviterID returns value of InviterID field.
func ( *ChatParticipantAdmin) () ( int64) {
	if  == nil {
		return
	}
	return .InviterID
}

// GetDate returns value of Date field.
func ( *ChatParticipantAdmin) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// ChatParticipantClassName is schema name of ChatParticipantClass.
const ChatParticipantClassName = "ChatParticipant"

// ChatParticipantClass represents ChatParticipant generic type.
//
// See https://core.telegram.org/type/ChatParticipant for reference.
//
// Example:
//
//	g, err := tg.DecodeChatParticipant(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ChatParticipant: // chatParticipant#c02d4007
//	case *tg.ChatParticipantCreator: // chatParticipantCreator#e46bcee4
//	case *tg.ChatParticipantAdmin: // chatParticipantAdmin#a0933f5b
//	default: panic(v)
//	}
type ChatParticipantClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChatParticipantClass

	// 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

	// Member user ID
	GetUserID() (value int64)
}

// DecodeChatParticipant implements binary de-serialization for ChatParticipantClass.
func ( *bin.Buffer) (ChatParticipantClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ChatParticipantTypeID:
		// Decoding chatParticipant#c02d4007.
		 := ChatParticipant{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatParticipantClass: %w", )
		}
		return &, nil
	case ChatParticipantCreatorTypeID:
		// Decoding chatParticipantCreator#e46bcee4.
		 := ChatParticipantCreator{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatParticipantClass: %w", )
		}
		return &, nil
	case ChatParticipantAdminTypeID:
		// Decoding chatParticipantAdmin#a0933f5b.
		 := ChatParticipantAdmin{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatParticipantClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ChatParticipantClass: %w", bin.NewUnexpectedID())
	}
}

// ChatParticipant boxes the ChatParticipantClass providing a helper.
type ChatParticipantBox struct {
	ChatParticipant ChatParticipantClass
}

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

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