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

// AutoSaveException represents TL type `autoSaveException#81602d47`.
// Peer-specific media autosave settings
//
// See https://core.telegram.org/constructor/autoSaveException for reference.
type AutoSaveException struct {
	// The peer
	Peer PeerClass
	// Media autosave settings
	Settings AutoSaveSettings
}

// AutoSaveExceptionTypeID is TL type id of AutoSaveException.
const AutoSaveExceptionTypeID = 0x81602d47

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

func ( *AutoSaveException) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Settings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AutoSaveException from given interface.
func ( *AutoSaveException) ( interface {
	() ( PeerClass)
	() ( AutoSaveSettings)
}) {
	.Peer = .()
	.Settings = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AutoSaveException) () tdp.Type {
	 := tdp.Type{
		Name: "autoSaveException",
		ID:   AutoSaveExceptionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Settings",
			SchemaName: "settings",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AutoSaveException) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode autoSaveException#81602d47 as nil")
	}
	.PutID(AutoSaveExceptionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AutoSaveException) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode autoSaveException#81602d47 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode autoSaveException#81602d47: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode autoSaveException#81602d47: field peer: %w", )
	}
	if  := .Settings.Encode();  != nil {
		return fmt.Errorf("unable to encode autoSaveException#81602d47: field settings: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AutoSaveException) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode autoSaveException#81602d47 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode autoSaveException#81602d47: field peer: %w", )
		}
		.Peer = 
	}
	{
		if  := .Settings.Decode();  != nil {
			return fmt.Errorf("unable to decode autoSaveException#81602d47: field settings: %w", )
		}
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *AutoSaveException) () ( PeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetSettings returns value of Settings field.
func ( *AutoSaveException) () ( AutoSaveSettings) {
	if  == nil {
		return
	}
	return .Settings
}