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

// ChannelsChannelParticipant represents TL type `channels.channelParticipant#dfb80317`.
// Represents a channel participant
//
// See https://core.telegram.org/constructor/channels.channelParticipant for reference.
type ChannelsChannelParticipant struct {
	// The channel participant
	Participant ChannelParticipantClass
	// Mentioned chats
	Chats []ChatClass
	// Users
	Users []UserClass
}

// ChannelsChannelParticipantTypeID is TL type id of ChannelsChannelParticipant.
const ChannelsChannelParticipantTypeID = 0xdfb80317

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

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

	return true
}

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

// FillFrom fills ChannelsChannelParticipant from given interface.
func ( *ChannelsChannelParticipant) ( interface {
	() ( ChannelParticipantClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Participant = .()
	.Chats = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsChannelParticipant) () tdp.Type {
	 := tdp.Type{
		Name: "channels.channelParticipant",
		ID:   ChannelsChannelParticipantTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Participant",
			SchemaName: "participant",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsChannelParticipant) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.channelParticipant#dfb80317 as nil")
	}
	.PutID(ChannelsChannelParticipantTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsChannelParticipant) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.channelParticipant#dfb80317 to nil")
	}
	{
		,  := DecodeChannelParticipant()
		if  != nil {
			return fmt.Errorf("unable to decode channels.channelParticipant#dfb80317: field participant: %w", )
		}
		.Participant = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.channelParticipant#dfb80317: field chats: %w", )
		}

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

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

// GetParticipant returns value of Participant field.
func ( *ChannelsChannelParticipant) () ( ChannelParticipantClass) {
	if  == nil {
		return
	}
	return .Participant
}

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

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

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

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