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

// MessagesHistoryImportParsed represents TL type `messages.historyImportParsed#5e0fb7b9`.
// Contains information about a chat export file generated by a foreign chat app, click
// here for more info¹.
// If neither the pm or group flags are set, the specified chat export was generated from
// a chat of unknown type.
//
// Links:
//  1. https://core.telegram.org/api/import
//
// See https://core.telegram.org/constructor/messages.historyImportParsed for reference.
type MessagesHistoryImportParsed struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The chat export file was generated from a private chat.
	Pm bool
	// The chat export file was generated from a group chat.
	Group bool
	// Title of the chat.
	//
	// Use SetTitle and GetTitle helpers.
	Title string
}

// MessagesHistoryImportParsedTypeID is TL type id of MessagesHistoryImportParsed.
const MessagesHistoryImportParsedTypeID = 0x5e0fb7b9

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

func ( *MessagesHistoryImportParsed) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Pm == false) {
		return false
	}
	if !(.Group == false) {
		return false
	}
	if !(.Title == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesHistoryImportParsed from given interface.
func ( *MessagesHistoryImportParsed) ( interface {
	() ( bool)
	() ( bool)
	() ( string,  bool)
}) {
	.Pm = .()
	.Group = .()
	if ,  := .();  {
		.Title = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesHistoryImportParsed) () tdp.Type {
	 := tdp.Type{
		Name: "messages.historyImportParsed",
		ID:   MessagesHistoryImportParsedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pm",
			SchemaName: "pm",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Group",
			SchemaName: "group",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesHistoryImportParsed) () {
	if !(.Pm == false) {
		.Flags.Set(0)
	}
	if !(.Group == false) {
		.Flags.Set(1)
	}
	if !(.Title == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesHistoryImportParsed) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.historyImportParsed#5e0fb7b9 as nil")
	}
	.PutID(MessagesHistoryImportParsedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesHistoryImportParsed) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.historyImportParsed#5e0fb7b9 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.historyImportParsed#5e0fb7b9: field flags: %w", )
	}
	if .Flags.Has(2) {
		.PutString(.Title)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesHistoryImportParsed) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.historyImportParsed#5e0fb7b9 to nil")
	}
	if  := .ConsumeID(MessagesHistoryImportParsedTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.historyImportParsed#5e0fb7b9: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesHistoryImportParsed) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.historyImportParsed#5e0fb7b9 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.historyImportParsed#5e0fb7b9: field flags: %w", )
		}
	}
	.Pm = .Flags.Has(0)
	.Group = .Flags.Has(1)
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.historyImportParsed#5e0fb7b9: field title: %w", )
		}
		.Title = 
	}
	return nil
}

// SetPm sets value of Pm conditional field.
func ( *MessagesHistoryImportParsed) ( bool) {
	if  {
		.Flags.Set(0)
		.Pm = true
	} else {
		.Flags.Unset(0)
		.Pm = false
	}
}

// GetPm returns value of Pm conditional field.
func ( *MessagesHistoryImportParsed) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetGroup sets value of Group conditional field.
func ( *MessagesHistoryImportParsed) ( bool) {
	if  {
		.Flags.Set(1)
		.Group = true
	} else {
		.Flags.Unset(1)
		.Group = false
	}
}

// GetGroup returns value of Group conditional field.
func ( *MessagesHistoryImportParsed) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetTitle sets value of Title conditional field.
func ( *MessagesHistoryImportParsed) ( string) {
	.Flags.Set(2)
	.Title = 
}

// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func ( *MessagesHistoryImportParsed) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Title, true
}