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

// ContactsResolvedPeer represents TL type `contacts.resolvedPeer#7f077ad9`.
// Resolved peer
//
// See https://core.telegram.org/constructor/contacts.resolvedPeer for reference.
type ContactsResolvedPeer struct {
	// The peer
	Peer PeerClass
	// Chats
	Chats []ChatClass
	// Users
	Users []UserClass
}

// ContactsResolvedPeerTypeID is TL type id of ContactsResolvedPeer.
const ContactsResolvedPeerTypeID = 0x7f077ad9

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

func ( *ContactsResolvedPeer) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsResolvedPeer from given interface.
func ( *ContactsResolvedPeer) ( interface {
	() ( PeerClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Peer = .()
	.Chats = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ContactsResolvedPeer) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.resolvedPeer",
		ID:   ContactsResolvedPeerTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactsResolvedPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.resolvedPeer#7f077ad9 as nil")
	}
	.PutID(ContactsResolvedPeerTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsResolvedPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.resolvedPeer#7f077ad9 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode contacts.resolvedPeer#7f077ad9: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.resolvedPeer#7f077ad9: field peer: %w", )
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode contacts.resolvedPeer#7f077ad9: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.resolvedPeer#7f077ad9: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode contacts.resolvedPeer#7f077ad9: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.resolvedPeer#7f077ad9: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ContactsResolvedPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.resolvedPeer#7f077ad9 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.resolvedPeer#7f077ad9: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.resolvedPeer#7f077ad9: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode contacts.resolvedPeer#7f077ad9: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.resolvedPeer#7f077ad9: field users: %w", )
		}

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

// GetPeer returns value of Peer field.
func ( *ContactsResolvedPeer) () ( PeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetChats returns value of Chats field.
func ( *ContactsResolvedPeer) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

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

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *ContactsResolvedPeer) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

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