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

// InvokeWithLayerRequest represents TL type `invokeWithLayer#da9b0d0d`.
// Invoke the specified query using the specified API layer¹
//
// Links:
//  1. https://core.telegram.org/api/invoking#layers
//
// See https://core.telegram.org/constructor/invokeWithLayer for reference.
type InvokeWithLayerRequest struct {
	// The layer to use
	Layer int
	// The query
	Query bin.Object
}

// InvokeWithLayerRequestTypeID is TL type id of InvokeWithLayerRequest.
const InvokeWithLayerRequestTypeID = 0xda9b0d0d

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

func ( *InvokeWithLayerRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Layer == 0) {
		return false
	}
	if !(.Query == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InvokeWithLayerRequest from given interface.
func ( *InvokeWithLayerRequest) ( interface {
	() ( int)
	() ( bin.Object)
}) {
	.Layer = .()
	.Query = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InvokeWithLayerRequest) () tdp.Type {
	 := tdp.Type{
		Name: "invokeWithLayer",
		ID:   InvokeWithLayerRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Layer",
			SchemaName: "layer",
		},
		{
			Name:       "Query",
			SchemaName: "query",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InvokeWithLayerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode invokeWithLayer#da9b0d0d as nil")
	}
	.PutID(InvokeWithLayerRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InvokeWithLayerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode invokeWithLayer#da9b0d0d as nil")
	}
	.PutInt(.Layer)
	if  := .Query.Encode();  != nil {
		return fmt.Errorf("unable to encode invokeWithLayer#da9b0d0d: field query: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InvokeWithLayerRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode invokeWithLayer#da9b0d0d to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode invokeWithLayer#da9b0d0d: field layer: %w", )
		}
		.Layer = 
	}
	{
		if  := .Query.Decode();  != nil {
			return fmt.Errorf("unable to decode invokeWithLayer#da9b0d0d: field query: %w", )
		}
	}
	return nil
}

// GetLayer returns value of Layer field.
func ( *InvokeWithLayerRequest) () ( int) {
	if  == nil {
		return
	}
	return .Layer
}

// GetQuery returns value of Query field.
func ( *InvokeWithLayerRequest) () ( bin.Object) {
	if  == nil {
		return
	}
	return .Query
}