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

// AccountContentSettings represents TL type `account.contentSettings#57e28221`.
// Sensitive content settings
//
// See https://core.telegram.org/constructor/account.contentSettings for reference.
type AccountContentSettings struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether viewing of sensitive (NSFW) content is enabled
	SensitiveEnabled bool
	// Whether the current client can change the sensitive content settings to view NSFW
	// content
	SensitiveCanChange bool
}

// AccountContentSettingsTypeID is TL type id of AccountContentSettings.
const AccountContentSettingsTypeID = 0x57e28221

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

func ( *AccountContentSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.SensitiveEnabled == false) {
		return false
	}
	if !(.SensitiveCanChange == false) {
		return false
	}

	return true
}

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

// FillFrom fills AccountContentSettings from given interface.
func ( *AccountContentSettings) ( interface {
	() ( bool)
	() ( bool)
}) {
	.SensitiveEnabled = .()
	.SensitiveCanChange = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountContentSettings) () tdp.Type {
	 := tdp.Type{
		Name: "account.contentSettings",
		ID:   AccountContentSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "SensitiveEnabled",
			SchemaName: "sensitive_enabled",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "SensitiveCanChange",
			SchemaName: "sensitive_can_change",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountContentSettings) () {
	if !(.SensitiveEnabled == false) {
		.Flags.Set(0)
	}
	if !(.SensitiveCanChange == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AccountContentSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.contentSettings#57e28221 as nil")
	}
	.PutID(AccountContentSettingsTypeID)
	return .EncodeBare()
}

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

// Decode implements bin.Decoder.
func ( *AccountContentSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.contentSettings#57e28221 to nil")
	}
	if  := .ConsumeID(AccountContentSettingsTypeID);  != nil {
		return fmt.Errorf("unable to decode account.contentSettings#57e28221: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountContentSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.contentSettings#57e28221 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.contentSettings#57e28221: field flags: %w", )
		}
	}
	.SensitiveEnabled = .Flags.Has(0)
	.SensitiveCanChange = .Flags.Has(1)
	return nil
}

// SetSensitiveEnabled sets value of SensitiveEnabled conditional field.
func ( *AccountContentSettings) ( bool) {
	if  {
		.Flags.Set(0)
		.SensitiveEnabled = true
	} else {
		.Flags.Unset(0)
		.SensitiveEnabled = false
	}
}

// GetSensitiveEnabled returns value of SensitiveEnabled conditional field.
func ( *AccountContentSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetSensitiveCanChange sets value of SensitiveCanChange conditional field.
func ( *AccountContentSettings) ( bool) {
	if  {
		.Flags.Set(1)
		.SensitiveCanChange = true
	} else {
		.Flags.Unset(1)
		.SensitiveCanChange = false
	}
}

// GetSensitiveCanChange returns value of SensitiveCanChange conditional field.
func ( *AccountContentSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}