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

// MessagesSentEncryptedMessage represents TL type `messages.sentEncryptedMessage#560f8935`.
// Message without file attachments sent to an encrypted file.
//
// See https://core.telegram.org/constructor/messages.sentEncryptedMessage for reference.
type MessagesSentEncryptedMessage struct {
	// Date of sending
	Date int
}

// MessagesSentEncryptedMessageTypeID is TL type id of MessagesSentEncryptedMessage.
const MessagesSentEncryptedMessageTypeID = 0x560f8935

// construct implements constructor of MessagesSentEncryptedMessageClass.
func ( MessagesSentEncryptedMessage) () MessagesSentEncryptedMessageClass { return & }

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

	_ MessagesSentEncryptedMessageClass = &MessagesSentEncryptedMessage{}
)

func ( *MessagesSentEncryptedMessage) () bool {
	if  == nil {
		return true
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSentEncryptedMessage from given interface.
func ( *MessagesSentEncryptedMessage) ( interface {
	() ( int)
}) {
	.Date = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesSentEncryptedMessage) () string {
	return "messages.sentEncryptedMessage"
}

// TypeInfo returns info about TL type.
func ( *MessagesSentEncryptedMessage) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sentEncryptedMessage",
		ID:   MessagesSentEncryptedMessageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSentEncryptedMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sentEncryptedMessage#560f8935 as nil")
	}
	.PutID(MessagesSentEncryptedMessageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSentEncryptedMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sentEncryptedMessage#560f8935 as nil")
	}
	.PutInt(.Date)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSentEncryptedMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sentEncryptedMessage#560f8935 to nil")
	}
	if  := .ConsumeID(MessagesSentEncryptedMessageTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.sentEncryptedMessage#560f8935: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSentEncryptedMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sentEncryptedMessage#560f8935 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sentEncryptedMessage#560f8935: field date: %w", )
		}
		.Date = 
	}
	return nil
}

// GetDate returns value of Date field.
func ( *MessagesSentEncryptedMessage) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// MessagesSentEncryptedFile represents TL type `messages.sentEncryptedFile#9493ff32`.
// Message with a file enclosure sent to a protected chat
//
// See https://core.telegram.org/constructor/messages.sentEncryptedFile for reference.
type MessagesSentEncryptedFile struct {
	// Sending date
	Date int
	// Attached file
	File EncryptedFileClass
}

// MessagesSentEncryptedFileTypeID is TL type id of MessagesSentEncryptedFile.
const MessagesSentEncryptedFileTypeID = 0x9493ff32

// construct implements constructor of MessagesSentEncryptedMessageClass.
func ( MessagesSentEncryptedFile) () MessagesSentEncryptedMessageClass { return & }

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

	_ MessagesSentEncryptedMessageClass = &MessagesSentEncryptedFile{}
)

func ( *MessagesSentEncryptedFile) () bool {
	if  == nil {
		return true
	}
	if !(.Date == 0) {
		return false
	}
	if !(.File == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSentEncryptedFile from given interface.
func ( *MessagesSentEncryptedFile) ( interface {
	() ( int)
	() ( EncryptedFileClass)
}) {
	.Date = .()
	.File = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesSentEncryptedFile) () string {
	return "messages.sentEncryptedFile"
}

// TypeInfo returns info about TL type.
func ( *MessagesSentEncryptedFile) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sentEncryptedFile",
		ID:   MessagesSentEncryptedFileTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "File",
			SchemaName: "file",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSentEncryptedFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sentEncryptedFile#9493ff32 as nil")
	}
	.PutID(MessagesSentEncryptedFileTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSentEncryptedFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sentEncryptedFile#9493ff32 as nil")
	}
	.PutInt(.Date)
	if .File == nil {
		return fmt.Errorf("unable to encode messages.sentEncryptedFile#9493ff32: field file is nil")
	}
	if  := .File.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sentEncryptedFile#9493ff32: field file: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSentEncryptedFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sentEncryptedFile#9493ff32 to nil")
	}
	if  := .ConsumeID(MessagesSentEncryptedFileTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.sentEncryptedFile#9493ff32: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSentEncryptedFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sentEncryptedFile#9493ff32 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sentEncryptedFile#9493ff32: field date: %w", )
		}
		.Date = 
	}
	{
		,  := DecodeEncryptedFile()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sentEncryptedFile#9493ff32: field file: %w", )
		}
		.File = 
	}
	return nil
}

// GetDate returns value of Date field.
func ( *MessagesSentEncryptedFile) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetFile returns value of File field.
func ( *MessagesSentEncryptedFile) () ( EncryptedFileClass) {
	if  == nil {
		return
	}
	return .File
}

// MessagesSentEncryptedMessageClassName is schema name of MessagesSentEncryptedMessageClass.
const MessagesSentEncryptedMessageClassName = "messages.SentEncryptedMessage"

// MessagesSentEncryptedMessageClass represents messages.SentEncryptedMessage generic type.
//
// See https://core.telegram.org/type/messages.SentEncryptedMessage for reference.
//
// Example:
//
//	g, err := tg.DecodeMessagesSentEncryptedMessage(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessagesSentEncryptedMessage: // messages.sentEncryptedMessage#560f8935
//	case *tg.MessagesSentEncryptedFile: // messages.sentEncryptedFile#9493ff32
//	default: panic(v)
//	}
type MessagesSentEncryptedMessageClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagesSentEncryptedMessageClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// Date of sending
	GetDate() (value int)
}

// DecodeMessagesSentEncryptedMessage implements binary de-serialization for MessagesSentEncryptedMessageClass.
func ( *bin.Buffer) (MessagesSentEncryptedMessageClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessagesSentEncryptedMessageTypeID:
		// Decoding messages.sentEncryptedMessage#560f8935.
		 := MessagesSentEncryptedMessage{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesSentEncryptedMessageClass: %w", )
		}
		return &, nil
	case MessagesSentEncryptedFileTypeID:
		// Decoding messages.sentEncryptedFile#9493ff32.
		 := MessagesSentEncryptedFile{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesSentEncryptedMessageClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessagesSentEncryptedMessageClass: %w", bin.NewUnexpectedID())
	}
}

// MessagesSentEncryptedMessage boxes the MessagesSentEncryptedMessageClass providing a helper.
type MessagesSentEncryptedMessageBox struct {
	SentEncryptedMessage MessagesSentEncryptedMessageClass
}

// Decode implements bin.Decoder for MessagesSentEncryptedMessageBox.
func ( *MessagesSentEncryptedMessageBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode MessagesSentEncryptedMessageBox to nil")
	}
	,  := DecodeMessagesSentEncryptedMessage()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.SentEncryptedMessage = 
	return nil
}

// Encode implements bin.Encode for MessagesSentEncryptedMessageBox.
func ( *MessagesSentEncryptedMessageBox) ( *bin.Buffer) error {
	if  == nil || .SentEncryptedMessage == nil {
		return fmt.Errorf("unable to encode MessagesSentEncryptedMessageClass as nil")
	}
	return .SentEncryptedMessage.Encode()
}