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

// PhoneJoinAsPeers represents TL type `phone.joinAsPeers#afe5623f`.
// A list of peers that can be used to join a group call, presenting yourself as a
// specific user/channel.
//
// See https://core.telegram.org/constructor/phone.joinAsPeers for reference.
type PhoneJoinAsPeers struct {
	// Peers
	Peers []PeerClass
	// Chats mentioned in the peers vector
	Chats []ChatClass
	// Users mentioned in the peers vector
	Users []UserClass
}

// PhoneJoinAsPeersTypeID is TL type id of PhoneJoinAsPeers.
const PhoneJoinAsPeersTypeID = 0xafe5623f

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

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

	return true
}

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

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

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

// TypeName returns name of type in TL schema.
func (*PhoneJoinAsPeers) () string {
	return "phone.joinAsPeers"
}

// TypeInfo returns info about TL type.
func ( *PhoneJoinAsPeers) () tdp.Type {
	 := tdp.Type{
		Name: "phone.joinAsPeers",
		ID:   PhoneJoinAsPeersTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peers",
			SchemaName: "peers",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneJoinAsPeers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.joinAsPeers#afe5623f as nil")
	}
	.PutID(PhoneJoinAsPeersTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneJoinAsPeers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.joinAsPeers#afe5623f as nil")
	}
	.PutVectorHeader(len(.Peers))
	for ,  := range .Peers {
		if  == nil {
			return fmt.Errorf("unable to encode phone.joinAsPeers#afe5623f: field peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode phone.joinAsPeers#afe5623f: field peers element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode phone.joinAsPeers#afe5623f: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode phone.joinAsPeers#afe5623f: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode phone.joinAsPeers#afe5623f: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode phone.joinAsPeers#afe5623f: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PhoneJoinAsPeers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.joinAsPeers#afe5623f to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode phone.joinAsPeers#afe5623f: field peers: %w", )
		}

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

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

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

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

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

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

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

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

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