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

// ChannelsSendAsPeers represents TL type `channels.sendAsPeers#f496b0c6`.
// A list of peers that can be used to send messages in a specific group
//
// See https://core.telegram.org/constructor/channels.sendAsPeers for reference.
type ChannelsSendAsPeers struct {
	// Peers that can be used to send messages to the group
	Peers []SendAsPeer
	// Mentioned chats
	Chats []ChatClass
	// Mentioned users
	Users []UserClass
}

// ChannelsSendAsPeersTypeID is TL type id of ChannelsSendAsPeers.
const ChannelsSendAsPeersTypeID = 0xf496b0c6

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

func ( *ChannelsSendAsPeers) () 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 ( *ChannelsSendAsPeers) () string {
	if  == nil {
		return "ChannelsSendAsPeers(nil)"
	}
	type  ChannelsSendAsPeers
	return fmt.Sprintf("ChannelsSendAsPeers%+v", (*))
}

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

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

// TypeName returns name of type in TL schema.
func (*ChannelsSendAsPeers) () string {
	return "channels.sendAsPeers"
}

// TypeInfo returns info about TL type.
func ( *ChannelsSendAsPeers) () tdp.Type {
	 := tdp.Type{
		Name: "channels.sendAsPeers",
		ID:   ChannelsSendAsPeersTypeID,
	}
	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 ( *ChannelsSendAsPeers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.sendAsPeers#f496b0c6 as nil")
	}
	.PutID(ChannelsSendAsPeersTypeID)
	return .EncodeBare()
}

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

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

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

		if  > 0 {
			.Peers = make([]SendAsPeer, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  SendAsPeer
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: field peers: %w", )
			}
			.Peers = append(.Peers, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.sendAsPeers#f496b0c6: field chats: %w", )
		}

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

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

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

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

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

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

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