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

// AccountAutoSaveSettings represents TL type `account.autoSaveSettings#4c3e069d`.
// Contains media autosave settings
//
// See https://core.telegram.org/constructor/account.autoSaveSettings for reference.
type AccountAutoSaveSettings struct {
	// Default media autosave settings for private chats
	UsersSettings AutoSaveSettings
	// Default media autosave settings for groups and supergroupsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	ChatsSettings AutoSaveSettings
	// Default media autosave settings for channelsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	BroadcastsSettings AutoSaveSettings
	// Peer-specific granular autosave settings
	Exceptions []AutoSaveException
	// Chats mentioned in the peer-specific granular autosave settings
	Chats []ChatClass
	// Users mentioned in the peer-specific granular autosave settings
	Users []UserClass
}

// AccountAutoSaveSettingsTypeID is TL type id of AccountAutoSaveSettings.
const AccountAutoSaveSettingsTypeID = 0x4c3e069d

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

func ( *AccountAutoSaveSettings) () bool {
	if  == nil {
		return true
	}
	if !(.UsersSettings.Zero()) {
		return false
	}
	if !(.ChatsSettings.Zero()) {
		return false
	}
	if !(.BroadcastsSettings.Zero()) {
		return false
	}
	if !(.Exceptions == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountAutoSaveSettings from given interface.
func ( *AccountAutoSaveSettings) ( interface {
	() ( AutoSaveSettings)
	() ( AutoSaveSettings)
	() ( AutoSaveSettings)
	() ( []AutoSaveException)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.UsersSettings = .()
	.ChatsSettings = .()
	.BroadcastsSettings = .()
	.Exceptions = .()
	.Chats = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountAutoSaveSettings) () string {
	return "account.autoSaveSettings"
}

// TypeInfo returns info about TL type.
func ( *AccountAutoSaveSettings) () tdp.Type {
	 := tdp.Type{
		Name: "account.autoSaveSettings",
		ID:   AccountAutoSaveSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UsersSettings",
			SchemaName: "users_settings",
		},
		{
			Name:       "ChatsSettings",
			SchemaName: "chats_settings",
		},
		{
			Name:       "BroadcastsSettings",
			SchemaName: "broadcasts_settings",
		},
		{
			Name:       "Exceptions",
			SchemaName: "exceptions",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountAutoSaveSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.autoSaveSettings#4c3e069d as nil")
	}
	.PutID(AccountAutoSaveSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountAutoSaveSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.autoSaveSettings#4c3e069d as nil")
	}
	if  := .UsersSettings.Encode();  != nil {
		return fmt.Errorf("unable to encode account.autoSaveSettings#4c3e069d: field users_settings: %w", )
	}
	if  := .ChatsSettings.Encode();  != nil {
		return fmt.Errorf("unable to encode account.autoSaveSettings#4c3e069d: field chats_settings: %w", )
	}
	if  := .BroadcastsSettings.Encode();  != nil {
		return fmt.Errorf("unable to encode account.autoSaveSettings#4c3e069d: field broadcasts_settings: %w", )
	}
	.PutVectorHeader(len(.Exceptions))
	for ,  := range .Exceptions {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.autoSaveSettings#4c3e069d: field exceptions element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode account.autoSaveSettings#4c3e069d: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.autoSaveSettings#4c3e069d: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode account.autoSaveSettings#4c3e069d: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.autoSaveSettings#4c3e069d: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountAutoSaveSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.autoSaveSettings#4c3e069d to nil")
	}
	if  := .ConsumeID(AccountAutoSaveSettingsTypeID);  != nil {
		return fmt.Errorf("unable to decode account.autoSaveSettings#4c3e069d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountAutoSaveSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.autoSaveSettings#4c3e069d to nil")
	}
	{
		if  := .UsersSettings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.autoSaveSettings#4c3e069d: field users_settings: %w", )
		}
	}
	{
		if  := .ChatsSettings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.autoSaveSettings#4c3e069d: field chats_settings: %w", )
		}
	}
	{
		if  := .BroadcastsSettings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.autoSaveSettings#4c3e069d: field broadcasts_settings: %w", )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.autoSaveSettings#4c3e069d: field exceptions: %w", )
		}

		if  > 0 {
			.Exceptions = make([]AutoSaveException, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  AutoSaveException
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.autoSaveSettings#4c3e069d: field exceptions: %w", )
			}
			.Exceptions = append(.Exceptions, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.autoSaveSettings#4c3e069d: field chats: %w", )
		}

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

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

// GetUsersSettings returns value of UsersSettings field.
func ( *AccountAutoSaveSettings) () ( AutoSaveSettings) {
	if  == nil {
		return
	}
	return .UsersSettings
}

// GetChatsSettings returns value of ChatsSettings field.
func ( *AccountAutoSaveSettings) () ( AutoSaveSettings) {
	if  == nil {
		return
	}
	return .ChatsSettings
}

// GetBroadcastsSettings returns value of BroadcastsSettings field.
func ( *AccountAutoSaveSettings) () ( AutoSaveSettings) {
	if  == nil {
		return
	}
	return .BroadcastsSettings
}

// GetExceptions returns value of Exceptions field.
func ( *AccountAutoSaveSettings) () ( []AutoSaveException) {
	if  == nil {
		return
	}
	return .Exceptions
}

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

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

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

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