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

// ContactsImportedContacts represents TL type `contacts.importedContacts#77d01c3b`.
// Info on successfully imported contacts.
//
// See https://core.telegram.org/constructor/contacts.importedContacts for reference.
type ContactsImportedContacts struct {
	// List of successfully imported contacts
	Imported []ImportedContact
	// Popular contacts
	PopularInvites []PopularContact
	// List of contact ids that could not be imported due to system limitation and will need
	// to be imported at a later date.
	RetryContacts []int64
	// List of users
	Users []UserClass
}

// ContactsImportedContactsTypeID is TL type id of ContactsImportedContacts.
const ContactsImportedContactsTypeID = 0x77d01c3b

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

func ( *ContactsImportedContacts) () bool {
	if  == nil {
		return true
	}
	if !(.Imported == nil) {
		return false
	}
	if !(.PopularInvites == nil) {
		return false
	}
	if !(.RetryContacts == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsImportedContacts from given interface.
func ( *ContactsImportedContacts) ( interface {
	() ( []ImportedContact)
	() ( []PopularContact)
	() ( []int64)
	() ( []UserClass)
}) {
	.Imported = .()
	.PopularInvites = .()
	.RetryContacts = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*ContactsImportedContacts) () string {
	return "contacts.importedContacts"
}

// TypeInfo returns info about TL type.
func ( *ContactsImportedContacts) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.importedContacts",
		ID:   ContactsImportedContactsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Imported",
			SchemaName: "imported",
		},
		{
			Name:       "PopularInvites",
			SchemaName: "popular_invites",
		},
		{
			Name:       "RetryContacts",
			SchemaName: "retry_contacts",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactsImportedContacts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.importedContacts#77d01c3b as nil")
	}
	.PutID(ContactsImportedContactsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsImportedContacts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.importedContacts#77d01c3b as nil")
	}
	.PutVectorHeader(len(.Imported))
	for ,  := range .Imported {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.importedContacts#77d01c3b: field imported element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.PopularInvites))
	for ,  := range .PopularInvites {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.importedContacts#77d01c3b: field popular_invites element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.RetryContacts))
	for ,  := range .RetryContacts {
		.PutLong()
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode contacts.importedContacts#77d01c3b: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.importedContacts#77d01c3b: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ContactsImportedContacts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.importedContacts#77d01c3b to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.importedContacts#77d01c3b: field imported: %w", )
		}

		if  > 0 {
			.Imported = make([]ImportedContact, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  ImportedContact
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode contacts.importedContacts#77d01c3b: field imported: %w", )
			}
			.Imported = append(.Imported, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.importedContacts#77d01c3b: field popular_invites: %w", )
		}

		if  > 0 {
			.PopularInvites = make([]PopularContact, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  PopularContact
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode contacts.importedContacts#77d01c3b: field popular_invites: %w", )
			}
			.PopularInvites = append(.PopularInvites, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.importedContacts#77d01c3b: field retry_contacts: %w", )
		}

		if  > 0 {
			.RetryContacts = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode contacts.importedContacts#77d01c3b: field retry_contacts: %w", )
			}
			.RetryContacts = append(.RetryContacts, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.importedContacts#77d01c3b: field users: %w", )
		}

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

// GetImported returns value of Imported field.
func ( *ContactsImportedContacts) () ( []ImportedContact) {
	if  == nil {
		return
	}
	return .Imported
}

// GetPopularInvites returns value of PopularInvites field.
func ( *ContactsImportedContacts) () ( []PopularContact) {
	if  == nil {
		return
	}
	return .PopularInvites
}

// GetRetryContacts returns value of RetryContacts field.
func ( *ContactsImportedContacts) () ( []int64) {
	if  == nil {
		return
	}
	return .RetryContacts
}

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

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