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

// FolderPeer represents TL type `folderPeer#e9baa668`.
// Peer in a folder
//
// See https://core.telegram.org/constructor/folderPeer for reference.
type FolderPeer struct {
	// Folder peer info
	Peer PeerClass
	// Peer folder ID, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders#peer-folders
	FolderID int
}

// FolderPeerTypeID is TL type id of FolderPeer.
const FolderPeerTypeID = 0xe9baa668

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

func ( *FolderPeer) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.FolderID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills FolderPeer from given interface.
func ( *FolderPeer) ( interface {
	() ( PeerClass)
	() ( int)
}) {
	.Peer = .()
	.FolderID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *FolderPeer) () tdp.Type {
	 := tdp.Type{
		Name: "folderPeer",
		ID:   FolderPeerTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "FolderID",
			SchemaName: "folder_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *FolderPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode folderPeer#e9baa668 as nil")
	}
	.PutID(FolderPeerTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *FolderPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode folderPeer#e9baa668 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode folderPeer#e9baa668: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode folderPeer#e9baa668: field peer: %w", )
	}
	.PutInt(.FolderID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *FolderPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode folderPeer#e9baa668 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode folderPeer#e9baa668: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode folderPeer#e9baa668: field folder_id: %w", )
		}
		.FolderID = 
	}
	return nil
}

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

// GetFolderID returns value of FolderID field.
func ( *FolderPeer) () ( int) {
	if  == nil {
		return
	}
	return .FolderID
}