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

// ContactsBlocked represents TL type `contacts.blocked#ade1591`.
// Full list of blocked users.
//
// See https://core.telegram.org/constructor/contacts.blocked for reference.
type ContactsBlocked struct {
	// List of blocked users
	Blocked []PeerBlocked
	// Blocked chats
	Chats []ChatClass
	// List of users
	Users []UserClass
}

// ContactsBlockedTypeID is TL type id of ContactsBlocked.
const ContactsBlockedTypeID = 0xade1591

// construct implements constructor of ContactsBlockedClass.
func ( ContactsBlocked) () ContactsBlockedClass { return & }

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

	_ ContactsBlockedClass = &ContactsBlocked{}
)

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

	return true
}

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

// FillFrom fills ContactsBlocked from given interface.
func ( *ContactsBlocked) ( interface {
	() ( []PeerBlocked)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Blocked = .()
	.Chats = .()
	.Users = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *ContactsBlocked) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.blocked#ade1591 as nil")
	}
	.PutID(ContactsBlockedTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ContactsBlocked) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.blocked#ade1591 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.blocked#ade1591: field blocked: %w", )
		}

		if  > 0 {
			.Blocked = make([]PeerBlocked, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  PeerBlocked
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode contacts.blocked#ade1591: field blocked: %w", )
			}
			.Blocked = append(.Blocked, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.blocked#ade1591: field chats: %w", )
		}

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

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

// GetBlocked returns value of Blocked field.
func ( *ContactsBlocked) () ( []PeerBlocked) {
	if  == nil {
		return
	}
	return .Blocked
}

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

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

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

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

// ContactsBlockedSlice represents TL type `contacts.blockedSlice#e1664194`.
// Incomplete list of blocked users.
//
// See https://core.telegram.org/constructor/contacts.blockedSlice for reference.
type ContactsBlockedSlice struct {
	// Total number of elements in the list
	Count int
	// List of blocked users
	Blocked []PeerBlocked
	// Blocked chats
	Chats []ChatClass
	// List of users
	Users []UserClass
}

// ContactsBlockedSliceTypeID is TL type id of ContactsBlockedSlice.
const ContactsBlockedSliceTypeID = 0xe1664194

// construct implements constructor of ContactsBlockedClass.
func ( ContactsBlockedSlice) () ContactsBlockedClass { return & }

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

	_ ContactsBlockedClass = &ContactsBlockedSlice{}
)

func ( *ContactsBlockedSlice) () bool {
	if  == nil {
		return true
	}
	if !(.Count == 0) {
		return false
	}
	if !(.Blocked == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsBlockedSlice from given interface.
func ( *ContactsBlockedSlice) ( interface {
	() ( int)
	() ( []PeerBlocked)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Count = .()
	.Blocked = .()
	.Chats = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ContactsBlockedSlice) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.blockedSlice",
		ID:   ContactsBlockedSliceTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Blocked",
			SchemaName: "blocked",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ContactsBlockedSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.blockedSlice#e1664194 as nil")
	}
	.PutID(ContactsBlockedSliceTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsBlockedSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.blockedSlice#e1664194 as nil")
	}
	.PutInt(.Count)
	.PutVectorHeader(len(.Blocked))
	for ,  := range .Blocked {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.blockedSlice#e1664194: field blocked element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode contacts.blockedSlice#e1664194: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.blockedSlice#e1664194: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode contacts.blockedSlice#e1664194: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode contacts.blockedSlice#e1664194: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ContactsBlockedSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.blockedSlice#e1664194 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.blockedSlice#e1664194: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.blockedSlice#e1664194: field blocked: %w", )
		}

		if  > 0 {
			.Blocked = make([]PeerBlocked, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  PeerBlocked
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode contacts.blockedSlice#e1664194: field blocked: %w", )
			}
			.Blocked = append(.Blocked, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.blockedSlice#e1664194: field chats: %w", )
		}

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

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

// GetCount returns value of Count field.
func ( *ContactsBlockedSlice) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

// GetBlocked returns value of Blocked field.
func ( *ContactsBlockedSlice) () ( []PeerBlocked) {
	if  == nil {
		return
	}
	return .Blocked
}

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

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

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

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

// ContactsBlockedClassName is schema name of ContactsBlockedClass.
const ContactsBlockedClassName = "contacts.Blocked"

// ContactsBlockedClass represents contacts.Blocked generic type.
//
// See https://core.telegram.org/type/contacts.Blocked for reference.
//
// Example:
//
//	g, err := tg.DecodeContactsBlocked(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ContactsBlocked: // contacts.blocked#ade1591
//	case *tg.ContactsBlockedSlice: // contacts.blockedSlice#e1664194
//	default: panic(v)
//	}
type ContactsBlockedClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ContactsBlockedClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// List of blocked users
	GetBlocked() (value []PeerBlocked)
	// Blocked chats
	GetChats() (value []ChatClass)
	// Blocked chats
	MapChats() (value ChatClassArray)
	// List of users
	GetUsers() (value []UserClass)
	// List of users
	MapUsers() (value UserClassArray)
}

// DecodeContactsBlocked implements binary de-serialization for ContactsBlockedClass.
func ( *bin.Buffer) (ContactsBlockedClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ContactsBlockedTypeID:
		// Decoding contacts.blocked#ade1591.
		 := ContactsBlocked{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ContactsBlockedClass: %w", )
		}
		return &, nil
	case ContactsBlockedSliceTypeID:
		// Decoding contacts.blockedSlice#e1664194.
		 := ContactsBlockedSlice{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ContactsBlockedClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ContactsBlockedClass: %w", bin.NewUnexpectedID())
	}
}

// ContactsBlocked boxes the ContactsBlockedClass providing a helper.
type ContactsBlockedBox struct {
	Blocked ContactsBlockedClass
}

// Decode implements bin.Decoder for ContactsBlockedBox.
func ( *ContactsBlockedBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode ContactsBlockedBox to nil")
	}
	,  := DecodeContactsBlocked()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.Blocked = 
	return nil
}

// Encode implements bin.Encode for ContactsBlockedBox.
func ( *ContactsBlockedBox) ( *bin.Buffer) error {
	if  == nil || .Blocked == nil {
		return fmt.Errorf("unable to encode ContactsBlockedClass as nil")
	}
	return .Blocked.Encode()
}