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

// ChannelsAdminLogResults represents TL type `channels.adminLogResults#ed8af74d`.
// Admin log events
//
// See https://core.telegram.org/constructor/channels.adminLogResults for reference.
type ChannelsAdminLogResults struct {
	// Admin log events
	Events []ChannelAdminLogEvent
	// Chats mentioned in events
	Chats []ChatClass
	// Users mentioned in events
	Users []UserClass
}

// ChannelsAdminLogResultsTypeID is TL type id of ChannelsAdminLogResults.
const ChannelsAdminLogResultsTypeID = 0xed8af74d

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

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

	return true
}

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

// FillFrom fills ChannelsAdminLogResults from given interface.
func ( *ChannelsAdminLogResults) ( interface {
	() ( []ChannelAdminLogEvent)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Events = .()
	.Chats = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsAdminLogResults) () tdp.Type {
	 := tdp.Type{
		Name: "channels.adminLogResults",
		ID:   ChannelsAdminLogResultsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Events",
			SchemaName: "events",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsAdminLogResults) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.adminLogResults#ed8af74d as nil")
	}
	.PutID(ChannelsAdminLogResultsTypeID)
	return .EncodeBare()
}

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

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

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

		if  > 0 {
			.Events = make([]ChannelAdminLogEvent, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  ChannelAdminLogEvent
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode channels.adminLogResults#ed8af74d: field events: %w", )
			}
			.Events = append(.Events, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.adminLogResults#ed8af74d: field chats: %w", )
		}

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

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

// GetEvents returns value of Events field.
func ( *ChannelsAdminLogResults) () ( []ChannelAdminLogEvent) {
	if  == nil {
		return
	}
	return .Events
}

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

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

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

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