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

// ExportedChatlistInvite represents TL type `exportedChatlistInvite#c5181ac`.
// Exported chat folder deep link »¹.
//
// Links:
//  1. https://core.telegram.org/api/links#chat-folder-links
//
// See https://core.telegram.org/constructor/exportedChatlistInvite for reference.
type ExportedChatlistInvite struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Name of the link
	Title string
	// The chat folder deep link »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#chat-folder-links
	URL string
	// Peers to import
	Peers []PeerClass
}

// ExportedChatlistInviteTypeID is TL type id of ExportedChatlistInvite.
const ExportedChatlistInviteTypeID = 0xc5181ac

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

func ( *ExportedChatlistInvite) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.URL == "") {
		return false
	}
	if !(.Peers == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ExportedChatlistInvite from given interface.
func ( *ExportedChatlistInvite) ( interface {
	() ( string)
	() ( string)
	() ( []PeerClass)
}) {
	.Title = .()
	.URL = .()
	.Peers = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ExportedChatlistInvite) () tdp.Type {
	 := tdp.Type{
		Name: "exportedChatlistInvite",
		ID:   ExportedChatlistInviteTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "Peers",
			SchemaName: "peers",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ExportedChatlistInvite) () {
}

// Encode implements bin.Encoder.
func ( *ExportedChatlistInvite) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode exportedChatlistInvite#c5181ac as nil")
	}
	.PutID(ExportedChatlistInviteTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ExportedChatlistInvite) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode exportedChatlistInvite#c5181ac as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode exportedChatlistInvite#c5181ac: field flags: %w", )
	}
	.PutString(.Title)
	.PutString(.URL)
	.PutVectorHeader(len(.Peers))
	for ,  := range .Peers {
		if  == nil {
			return fmt.Errorf("unable to encode exportedChatlistInvite#c5181ac: field peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode exportedChatlistInvite#c5181ac: field peers element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ExportedChatlistInvite) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode exportedChatlistInvite#c5181ac to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode exportedChatlistInvite#c5181ac: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode exportedChatlistInvite#c5181ac: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode exportedChatlistInvite#c5181ac: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode exportedChatlistInvite#c5181ac: field peers: %w", )
		}

		if  > 0 {
			.Peers = make([]PeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodePeer()
			if  != nil {
				return fmt.Errorf("unable to decode exportedChatlistInvite#c5181ac: field peers: %w", )
			}
			.Peers = append(.Peers, )
		}
	}
	return nil
}

// GetTitle returns value of Title field.
func ( *ExportedChatlistInvite) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// GetURL returns value of URL field.
func ( *ExportedChatlistInvite) () ( string) {
	if  == nil {
		return
	}
	return .URL
}

// GetPeers returns value of Peers field.
func ( *ExportedChatlistInvite) () ( []PeerClass) {
	if  == nil {
		return
	}
	return .Peers
}

// MapPeers returns field Peers wrapped in PeerClassArray helper.
func ( *ExportedChatlistInvite) () ( PeerClassArray) {
	return PeerClassArray(.Peers)
}