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

// MessagesExportedChatInvite represents TL type `messages.exportedChatInvite#1871be50`.
// Info about a chat invite
//
// See https://core.telegram.org/constructor/messages.exportedChatInvite for reference.
type MessagesExportedChatInvite struct {
	// Info about the chat invite
	Invite ExportedChatInviteClass
	// Mentioned users
	Users []UserClass
}

// MessagesExportedChatInviteTypeID is TL type id of MessagesExportedChatInvite.
const MessagesExportedChatInviteTypeID = 0x1871be50

// construct implements constructor of MessagesExportedChatInviteClass.
func ( MessagesExportedChatInvite) () MessagesExportedChatInviteClass { return & }

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

	_ MessagesExportedChatInviteClass = &MessagesExportedChatInvite{}
)

func ( *MessagesExportedChatInvite) () bool {
	if  == nil {
		return true
	}
	if !(.Invite == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesExportedChatInvite from given interface.
func ( *MessagesExportedChatInvite) ( interface {
	() ( ExportedChatInviteClass)
	() ( []UserClass)
}) {
	.Invite = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesExportedChatInvite) () string {
	return "messages.exportedChatInvite"
}

// TypeInfo returns info about TL type.
func ( *MessagesExportedChatInvite) () tdp.Type {
	 := tdp.Type{
		Name: "messages.exportedChatInvite",
		ID:   MessagesExportedChatInviteTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Invite",
			SchemaName: "invite",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesExportedChatInvite) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.exportedChatInvite#1871be50 as nil")
	}
	.PutID(MessagesExportedChatInviteTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesExportedChatInvite) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.exportedChatInvite#1871be50 as nil")
	}
	if .Invite == nil {
		return fmt.Errorf("unable to encode messages.exportedChatInvite#1871be50: field invite is nil")
	}
	if  := .Invite.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.exportedChatInvite#1871be50: field invite: %w", )
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.exportedChatInvite#1871be50: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.exportedChatInvite#1871be50: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesExportedChatInvite) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.exportedChatInvite#1871be50 to nil")
	}
	if  := .ConsumeID(MessagesExportedChatInviteTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.exportedChatInvite#1871be50: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesExportedChatInvite) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.exportedChatInvite#1871be50 to nil")
	}
	{
		,  := DecodeExportedChatInvite()
		if  != nil {
			return fmt.Errorf("unable to decode messages.exportedChatInvite#1871be50: field invite: %w", )
		}
		.Invite = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.exportedChatInvite#1871be50: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode messages.exportedChatInvite#1871be50: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetInvite returns value of Invite field.
func ( *MessagesExportedChatInvite) () ( ExportedChatInviteClass) {
	if  == nil {
		return
	}
	return .Invite
}

// GetUsers returns value of Users field.
func ( *MessagesExportedChatInvite) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *MessagesExportedChatInvite) () ( UserClassArray) {
	return UserClassArray(.Users)
}

// MessagesExportedChatInviteReplaced represents TL type `messages.exportedChatInviteReplaced#222600ef`.
// The specified chat invite was replaced with another one
//
// See https://core.telegram.org/constructor/messages.exportedChatInviteReplaced for reference.
type MessagesExportedChatInviteReplaced struct {
	// The replaced chat invite
	Invite ExportedChatInviteClass
	// The invite that replaces the previous invite
	NewInvite ExportedChatInviteClass
	// Mentioned users
	Users []UserClass
}

// MessagesExportedChatInviteReplacedTypeID is TL type id of MessagesExportedChatInviteReplaced.
const MessagesExportedChatInviteReplacedTypeID = 0x222600ef

// construct implements constructor of MessagesExportedChatInviteClass.
func ( MessagesExportedChatInviteReplaced) () MessagesExportedChatInviteClass { return & }

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

	_ MessagesExportedChatInviteClass = &MessagesExportedChatInviteReplaced{}
)

func ( *MessagesExportedChatInviteReplaced) () bool {
	if  == nil {
		return true
	}
	if !(.Invite == nil) {
		return false
	}
	if !(.NewInvite == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesExportedChatInviteReplaced from given interface.
func ( *MessagesExportedChatInviteReplaced) ( interface {
	() ( ExportedChatInviteClass)
	() ( ExportedChatInviteClass)
	() ( []UserClass)
}) {
	.Invite = .()
	.NewInvite = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesExportedChatInviteReplaced) () string {
	return "messages.exportedChatInviteReplaced"
}

// TypeInfo returns info about TL type.
func ( *MessagesExportedChatInviteReplaced) () tdp.Type {
	 := tdp.Type{
		Name: "messages.exportedChatInviteReplaced",
		ID:   MessagesExportedChatInviteReplacedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Invite",
			SchemaName: "invite",
		},
		{
			Name:       "NewInvite",
			SchemaName: "new_invite",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesExportedChatInviteReplaced) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.exportedChatInviteReplaced#222600ef as nil")
	}
	.PutID(MessagesExportedChatInviteReplacedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesExportedChatInviteReplaced) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.exportedChatInviteReplaced#222600ef as nil")
	}
	if .Invite == nil {
		return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field invite is nil")
	}
	if  := .Invite.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field invite: %w", )
	}
	if .NewInvite == nil {
		return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field new_invite is nil")
	}
	if  := .NewInvite.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field new_invite: %w", )
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesExportedChatInviteReplaced) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.exportedChatInviteReplaced#222600ef to nil")
	}
	if  := .ConsumeID(MessagesExportedChatInviteReplacedTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesExportedChatInviteReplaced) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.exportedChatInviteReplaced#222600ef to nil")
	}
	{
		,  := DecodeExportedChatInvite()
		if  != nil {
			return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: field invite: %w", )
		}
		.Invite = 
	}
	{
		,  := DecodeExportedChatInvite()
		if  != nil {
			return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: field new_invite: %w", )
		}
		.NewInvite = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetInvite returns value of Invite field.
func ( *MessagesExportedChatInviteReplaced) () ( ExportedChatInviteClass) {
	if  == nil {
		return
	}
	return .Invite
}

// GetNewInvite returns value of NewInvite field.
func ( *MessagesExportedChatInviteReplaced) () ( ExportedChatInviteClass) {
	if  == nil {
		return
	}
	return .NewInvite
}

// GetUsers returns value of Users field.
func ( *MessagesExportedChatInviteReplaced) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *MessagesExportedChatInviteReplaced) () ( UserClassArray) {
	return UserClassArray(.Users)
}

// MessagesExportedChatInviteClassName is schema name of MessagesExportedChatInviteClass.
const MessagesExportedChatInviteClassName = "messages.ExportedChatInvite"

// MessagesExportedChatInviteClass represents messages.ExportedChatInvite generic type.
//
// See https://core.telegram.org/type/messages.ExportedChatInvite for reference.
//
// Example:
//
//	g, err := tg.DecodeMessagesExportedChatInvite(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessagesExportedChatInvite: // messages.exportedChatInvite#1871be50
//	case *tg.MessagesExportedChatInviteReplaced: // messages.exportedChatInviteReplaced#222600ef
//	default: panic(v)
//	}
type MessagesExportedChatInviteClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagesExportedChatInviteClass

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

	// Info about the chat invite
	GetInvite() (value ExportedChatInviteClass)

	// Mentioned users
	GetUsers() (value []UserClass)
	// Mentioned users
	MapUsers() (value UserClassArray)
}

// DecodeMessagesExportedChatInvite implements binary de-serialization for MessagesExportedChatInviteClass.
func ( *bin.Buffer) (MessagesExportedChatInviteClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessagesExportedChatInviteTypeID:
		// Decoding messages.exportedChatInvite#1871be50.
		 := MessagesExportedChatInvite{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesExportedChatInviteClass: %w", )
		}
		return &, nil
	case MessagesExportedChatInviteReplacedTypeID:
		// Decoding messages.exportedChatInviteReplaced#222600ef.
		 := MessagesExportedChatInviteReplaced{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesExportedChatInviteClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessagesExportedChatInviteClass: %w", bin.NewUnexpectedID())
	}
}

// MessagesExportedChatInvite boxes the MessagesExportedChatInviteClass providing a helper.
type MessagesExportedChatInviteBox struct {
	ExportedChatInvite MessagesExportedChatInviteClass
}

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

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