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

// AutoDownloadSettings represents TL type `autoDownloadSettings#baa57628`.
// Autodownload settings
//
// See https://core.telegram.org/constructor/autoDownloadSettings for reference.
type AutoDownloadSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Disable automatic media downloads?
	Disabled bool
	// Whether to preload the first seconds of videos larger than the specified limit
	VideoPreloadLarge bool
	// Whether to preload the next audio track when you're listening to music
	AudioPreloadNext bool
	// Whether to enable data saving mode in phone calls
	PhonecallsLessData bool
	// Whether to preload stories¹; in particular, the first documentAttributeVideo²
	// preload_prefix_size bytes of story videos should be preloaded.
	//
	// Links:
	//  1) https://core.telegram.org/api/stories
	//  2) https://core.telegram.org/constructor/documentAttributeVideo
	StoriesPreload bool
	// Maximum size of photos to preload
	PhotoSizeMax int
	// Maximum size of videos to preload
	VideoSizeMax int64
	// Maximum size of other files to preload
	FileSizeMax int64
	// Maximum suggested bitrate for uploading videos
	VideoUploadMaxbitrate int
	// SmallQueueActiveOperationsMax field of AutoDownloadSettings.
	SmallQueueActiveOperationsMax int
	// LargeQueueActiveOperationsMax field of AutoDownloadSettings.
	LargeQueueActiveOperationsMax int
}

// AutoDownloadSettingsTypeID is TL type id of AutoDownloadSettings.
const AutoDownloadSettingsTypeID = 0xbaa57628

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

func ( *AutoDownloadSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Disabled == false) {
		return false
	}
	if !(.VideoPreloadLarge == false) {
		return false
	}
	if !(.AudioPreloadNext == false) {
		return false
	}
	if !(.PhonecallsLessData == false) {
		return false
	}
	if !(.StoriesPreload == false) {
		return false
	}
	if !(.PhotoSizeMax == 0) {
		return false
	}
	if !(.VideoSizeMax == 0) {
		return false
	}
	if !(.FileSizeMax == 0) {
		return false
	}
	if !(.VideoUploadMaxbitrate == 0) {
		return false
	}
	if !(.SmallQueueActiveOperationsMax == 0) {
		return false
	}
	if !(.LargeQueueActiveOperationsMax == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AutoDownloadSettings from given interface.
func ( *AutoDownloadSettings) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int)
	() ( int64)
	() ( int64)
	() ( int)
	() ( int)
	() ( int)
}) {
	.Disabled = .()
	.VideoPreloadLarge = .()
	.AudioPreloadNext = .()
	.PhonecallsLessData = .()
	.StoriesPreload = .()
	.PhotoSizeMax = .()
	.VideoSizeMax = .()
	.FileSizeMax = .()
	.VideoUploadMaxbitrate = .()
	.SmallQueueActiveOperationsMax = .()
	.LargeQueueActiveOperationsMax = .()
}

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

// TypeName returns name of type in TL schema.
func (*AutoDownloadSettings) () string {
	return "autoDownloadSettings"
}

// TypeInfo returns info about TL type.
func ( *AutoDownloadSettings) () tdp.Type {
	 := tdp.Type{
		Name: "autoDownloadSettings",
		ID:   AutoDownloadSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Disabled",
			SchemaName: "disabled",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "VideoPreloadLarge",
			SchemaName: "video_preload_large",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "AudioPreloadNext",
			SchemaName: "audio_preload_next",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "PhonecallsLessData",
			SchemaName: "phonecalls_less_data",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "StoriesPreload",
			SchemaName: "stories_preload",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "PhotoSizeMax",
			SchemaName: "photo_size_max",
		},
		{
			Name:       "VideoSizeMax",
			SchemaName: "video_size_max",
		},
		{
			Name:       "FileSizeMax",
			SchemaName: "file_size_max",
		},
		{
			Name:       "VideoUploadMaxbitrate",
			SchemaName: "video_upload_maxbitrate",
		},
		{
			Name:       "SmallQueueActiveOperationsMax",
			SchemaName: "small_queue_active_operations_max",
		},
		{
			Name:       "LargeQueueActiveOperationsMax",
			SchemaName: "large_queue_active_operations_max",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AutoDownloadSettings) () {
	if !(.Disabled == false) {
		.Flags.Set(0)
	}
	if !(.VideoPreloadLarge == false) {
		.Flags.Set(1)
	}
	if !(.AudioPreloadNext == false) {
		.Flags.Set(2)
	}
	if !(.PhonecallsLessData == false) {
		.Flags.Set(3)
	}
	if !(.StoriesPreload == false) {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *AutoDownloadSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode autoDownloadSettings#baa57628 as nil")
	}
	.PutID(AutoDownloadSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AutoDownloadSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode autoDownloadSettings#baa57628 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode autoDownloadSettings#baa57628: field flags: %w", )
	}
	.PutInt(.PhotoSizeMax)
	.PutLong(.VideoSizeMax)
	.PutLong(.FileSizeMax)
	.PutInt(.VideoUploadMaxbitrate)
	.PutInt(.SmallQueueActiveOperationsMax)
	.PutInt(.LargeQueueActiveOperationsMax)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AutoDownloadSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode autoDownloadSettings#baa57628 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode autoDownloadSettings#baa57628: field flags: %w", )
		}
	}
	.Disabled = .Flags.Has(0)
	.VideoPreloadLarge = .Flags.Has(1)
	.AudioPreloadNext = .Flags.Has(2)
	.PhonecallsLessData = .Flags.Has(3)
	.StoriesPreload = .Flags.Has(4)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode autoDownloadSettings#baa57628: field photo_size_max: %w", )
		}
		.PhotoSizeMax = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode autoDownloadSettings#baa57628: field video_size_max: %w", )
		}
		.VideoSizeMax = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode autoDownloadSettings#baa57628: field file_size_max: %w", )
		}
		.FileSizeMax = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode autoDownloadSettings#baa57628: field video_upload_maxbitrate: %w", )
		}
		.VideoUploadMaxbitrate = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode autoDownloadSettings#baa57628: field small_queue_active_operations_max: %w", )
		}
		.SmallQueueActiveOperationsMax = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode autoDownloadSettings#baa57628: field large_queue_active_operations_max: %w", )
		}
		.LargeQueueActiveOperationsMax = 
	}
	return nil
}

// SetDisabled sets value of Disabled conditional field.
func ( *AutoDownloadSettings) ( bool) {
	if  {
		.Flags.Set(0)
		.Disabled = true
	} else {
		.Flags.Unset(0)
		.Disabled = false
	}
}

// GetDisabled returns value of Disabled conditional field.
func ( *AutoDownloadSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetVideoPreloadLarge sets value of VideoPreloadLarge conditional field.
func ( *AutoDownloadSettings) ( bool) {
	if  {
		.Flags.Set(1)
		.VideoPreloadLarge = true
	} else {
		.Flags.Unset(1)
		.VideoPreloadLarge = false
	}
}

// GetVideoPreloadLarge returns value of VideoPreloadLarge conditional field.
func ( *AutoDownloadSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetAudioPreloadNext sets value of AudioPreloadNext conditional field.
func ( *AutoDownloadSettings) ( bool) {
	if  {
		.Flags.Set(2)
		.AudioPreloadNext = true
	} else {
		.Flags.Unset(2)
		.AudioPreloadNext = false
	}
}

// GetAudioPreloadNext returns value of AudioPreloadNext conditional field.
func ( *AutoDownloadSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetPhonecallsLessData sets value of PhonecallsLessData conditional field.
func ( *AutoDownloadSettings) ( bool) {
	if  {
		.Flags.Set(3)
		.PhonecallsLessData = true
	} else {
		.Flags.Unset(3)
		.PhonecallsLessData = false
	}
}

// GetPhonecallsLessData returns value of PhonecallsLessData conditional field.
func ( *AutoDownloadSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetStoriesPreload sets value of StoriesPreload conditional field.
func ( *AutoDownloadSettings) ( bool) {
	if  {
		.Flags.Set(4)
		.StoriesPreload = true
	} else {
		.Flags.Unset(4)
		.StoriesPreload = false
	}
}

// GetStoriesPreload returns value of StoriesPreload conditional field.
func ( *AutoDownloadSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// GetPhotoSizeMax returns value of PhotoSizeMax field.
func ( *AutoDownloadSettings) () ( int) {
	if  == nil {
		return
	}
	return .PhotoSizeMax
}

// GetVideoSizeMax returns value of VideoSizeMax field.
func ( *AutoDownloadSettings) () ( int64) {
	if  == nil {
		return
	}
	return .VideoSizeMax
}

// GetFileSizeMax returns value of FileSizeMax field.
func ( *AutoDownloadSettings) () ( int64) {
	if  == nil {
		return
	}
	return .FileSizeMax
}

// GetVideoUploadMaxbitrate returns value of VideoUploadMaxbitrate field.
func ( *AutoDownloadSettings) () ( int) {
	if  == nil {
		return
	}
	return .VideoUploadMaxbitrate
}

// GetSmallQueueActiveOperationsMax returns value of SmallQueueActiveOperationsMax field.
func ( *AutoDownloadSettings) () ( int) {
	if  == nil {
		return
	}
	return .SmallQueueActiveOperationsMax
}

// GetLargeQueueActiveOperationsMax returns value of LargeQueueActiveOperationsMax field.
func ( *AutoDownloadSettings) () ( int) {
	if  == nil {
		return
	}
	return .LargeQueueActiveOperationsMax
}