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

// TonConnectManifest represents TL type `tonConnectManifest#12229264`.
//
// See https://core.telegram.org/constructor/tonConnectManifest for reference.
type TonConnectManifest struct {
	// Flags field of TonConnectManifest.
	Flags bin.Fields
	// URL field of TonConnectManifest.
	URL string
	// Name field of TonConnectManifest.
	Name string
	// Icon field of TonConnectManifest.
	//
	// Use SetIcon and GetIcon helpers.
	Icon WebDocumentClass
}

// TonConnectManifestTypeID is TL type id of TonConnectManifest.
const TonConnectManifestTypeID = 0x12229264

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

func ( *TonConnectManifest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.URL == "") {
		return false
	}
	if !(.Name == "") {
		return false
	}
	if !(.Icon == nil) {
		return false
	}

	return true
}

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

// FillFrom fills TonConnectManifest from given interface.
func ( *TonConnectManifest) ( interface {
	() ( string)
	() ( string)
	() ( WebDocumentClass,  bool)
}) {
	.URL = .()
	.Name = .()
	if ,  := .();  {
		.Icon = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *TonConnectManifest) () tdp.Type {
	 := tdp.Type{
		Name: "tonConnectManifest",
		ID:   TonConnectManifestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "Name",
			SchemaName: "name",
		},
		{
			Name:       "Icon",
			SchemaName: "icon",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *TonConnectManifest) () {
	if !(.Icon == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *TonConnectManifest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode tonConnectManifest#12229264 as nil")
	}
	.PutID(TonConnectManifestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *TonConnectManifest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode tonConnectManifest#12229264 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode tonConnectManifest#12229264: field flags: %w", )
	}
	.PutString(.URL)
	.PutString(.Name)
	if .Flags.Has(0) {
		if .Icon == nil {
			return fmt.Errorf("unable to encode tonConnectManifest#12229264: field icon is nil")
		}
		if  := .Icon.Encode();  != nil {
			return fmt.Errorf("unable to encode tonConnectManifest#12229264: field icon: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *TonConnectManifest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode tonConnectManifest#12229264 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode tonConnectManifest#12229264: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode tonConnectManifest#12229264: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode tonConnectManifest#12229264: field name: %w", )
		}
		.Name = 
	}
	if .Flags.Has(0) {
		,  := DecodeWebDocument()
		if  != nil {
			return fmt.Errorf("unable to decode tonConnectManifest#12229264: field icon: %w", )
		}
		.Icon = 
	}
	return nil
}

// GetURL returns value of URL field.
func ( *TonConnectManifest) () ( string) {
	if  == nil {
		return
	}
	return .URL
}

// GetName returns value of Name field.
func ( *TonConnectManifest) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

// SetIcon sets value of Icon conditional field.
func ( *TonConnectManifest) ( WebDocumentClass) {
	.Flags.Set(0)
	.Icon = 
}

// GetIcon returns value of Icon conditional field and
// boolean which is true if field was set.
func ( *TonConnectManifest) () ( WebDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Icon, true
}