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

// GlobalPrivacySettings represents TL type `globalPrivacySettings#734c4ccb`.
// Global privacy settings
//
// See https://core.telegram.org/constructor/globalPrivacySettings for reference.
type GlobalPrivacySettings struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to archive and mute new chats from non-contacts
	ArchiveAndMuteNewNoncontactPeers bool
	// Whether unmuted chats will be kept in the Archive chat list when they get a new
	// message.
	KeepArchivedUnmuted bool
	// Whether unmuted chats that are always included or pinned in a folderĀ¹, will be kept
	// in the Archive chat list when they get a new message. Ignored if keep_archived_unmuted
	// is set.
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	KeepArchivedFolders bool
}

// GlobalPrivacySettingsTypeID is TL type id of GlobalPrivacySettings.
const GlobalPrivacySettingsTypeID = 0x734c4ccb

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

func ( *GlobalPrivacySettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ArchiveAndMuteNewNoncontactPeers == false) {
		return false
	}
	if !(.KeepArchivedUnmuted == false) {
		return false
	}
	if !(.KeepArchivedFolders == false) {
		return false
	}

	return true
}

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

// FillFrom fills GlobalPrivacySettings from given interface.
func ( *GlobalPrivacySettings) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
}) {
	.ArchiveAndMuteNewNoncontactPeers = .()
	.KeepArchivedUnmuted = .()
	.KeepArchivedFolders = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *GlobalPrivacySettings) () tdp.Type {
	 := tdp.Type{
		Name: "globalPrivacySettings",
		ID:   GlobalPrivacySettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ArchiveAndMuteNewNoncontactPeers",
			SchemaName: "archive_and_mute_new_noncontact_peers",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "KeepArchivedUnmuted",
			SchemaName: "keep_archived_unmuted",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "KeepArchivedFolders",
			SchemaName: "keep_archived_folders",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *GlobalPrivacySettings) () {
	if !(.ArchiveAndMuteNewNoncontactPeers == false) {
		.Flags.Set(0)
	}
	if !(.KeepArchivedUnmuted == false) {
		.Flags.Set(1)
	}
	if !(.KeepArchivedFolders == false) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *GlobalPrivacySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode globalPrivacySettings#734c4ccb as nil")
	}
	.PutID(GlobalPrivacySettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *GlobalPrivacySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode globalPrivacySettings#734c4ccb as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode globalPrivacySettings#734c4ccb: field flags: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *GlobalPrivacySettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode globalPrivacySettings#734c4ccb to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode globalPrivacySettings#734c4ccb: field flags: %w", )
		}
	}
	.ArchiveAndMuteNewNoncontactPeers = .Flags.Has(0)
	.KeepArchivedUnmuted = .Flags.Has(1)
	.KeepArchivedFolders = .Flags.Has(2)
	return nil
}

// SetArchiveAndMuteNewNoncontactPeers sets value of ArchiveAndMuteNewNoncontactPeers conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(0)
		.ArchiveAndMuteNewNoncontactPeers = true
	} else {
		.Flags.Unset(0)
		.ArchiveAndMuteNewNoncontactPeers = false
	}
}

// GetArchiveAndMuteNewNoncontactPeers returns value of ArchiveAndMuteNewNoncontactPeers conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetKeepArchivedUnmuted sets value of KeepArchivedUnmuted conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(1)
		.KeepArchivedUnmuted = true
	} else {
		.Flags.Unset(1)
		.KeepArchivedUnmuted = false
	}
}

// GetKeepArchivedUnmuted returns value of KeepArchivedUnmuted conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetKeepArchivedFolders sets value of KeepArchivedFolders conditional field.
func ( *GlobalPrivacySettings) ( bool) {
	if  {
		.Flags.Set(2)
		.KeepArchivedFolders = true
	} else {
		.Flags.Unset(2)
		.KeepArchivedFolders = false
	}
}

// GetKeepArchivedFolders returns value of KeepArchivedFolders conditional field.
func ( *GlobalPrivacySettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}