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

// RequestedPeerUser represents TL type `requestedPeerUser#d62ff46a`.
// Info about a user, shared by a user with the currently logged in bot using messages
// sendBotRequestedPeer¹.
// All fields except the ID are optional, and will be populated if present on the chosen
// user, according to the parameters of the requesting inputKeyboardButtonRequestPeer¹.
//
// Links:
//  1. https://core.telegram.org/method/messages.sendBotRequestedPeer
//  2. https://core.telegram.org/constructor/inputKeyboardButtonRequestPeer
//
// See https://core.telegram.org/constructor/requestedPeerUser for reference.
type RequestedPeerUser struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// User ID.
	UserID int64
	// First name.
	//
	// Use SetFirstName and GetFirstName helpers.
	FirstName string
	// Last name.
	//
	// Use SetLastName and GetLastName helpers.
	LastName string
	// Username.
	//
	// Use SetUsername and GetUsername helpers.
	Username string
	// Profile photo.
	//
	// Use SetPhoto and GetPhoto helpers.
	Photo PhotoClass
}

// RequestedPeerUserTypeID is TL type id of RequestedPeerUser.
const RequestedPeerUserTypeID = 0xd62ff46a

// construct implements constructor of RequestedPeerClass.
func ( RequestedPeerUser) () RequestedPeerClass { return & }

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

	_ RequestedPeerClass = &RequestedPeerUser{}
)

func ( *RequestedPeerUser) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.FirstName == "") {
		return false
	}
	if !(.LastName == "") {
		return false
	}
	if !(.Username == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}

	return true
}

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

// FillFrom fills RequestedPeerUser from given interface.
func ( *RequestedPeerUser) ( interface {
	() ( int64)
	() ( string,  bool)
	() ( string,  bool)
	() ( string,  bool)
	() ( PhotoClass,  bool)
}) {
	.UserID = .()
	if ,  := .();  {
		.FirstName = 
	}

	if ,  := .();  {
		.LastName = 
	}

	if ,  := .();  {
		.Username = 
	}

	if ,  := .();  {
		.Photo = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *RequestedPeerUser) () tdp.Type {
	 := tdp.Type{
		Name: "requestedPeerUser",
		ID:   RequestedPeerUserTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "FirstName",
			SchemaName: "first_name",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "LastName",
			SchemaName: "last_name",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Username",
			SchemaName: "username",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *RequestedPeerUser) () {
	if !(.FirstName == "") {
		.Flags.Set(0)
	}
	if !(.LastName == "") {
		.Flags.Set(0)
	}
	if !(.Username == "") {
		.Flags.Set(1)
	}
	if !(.Photo == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *RequestedPeerUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestedPeerUser#d62ff46a as nil")
	}
	.PutID(RequestedPeerUserTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RequestedPeerUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestedPeerUser#d62ff46a as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode requestedPeerUser#d62ff46a: field flags: %w", )
	}
	.PutLong(.UserID)
	if .Flags.Has(0) {
		.PutString(.FirstName)
	}
	if .Flags.Has(0) {
		.PutString(.LastName)
	}
	if .Flags.Has(1) {
		.PutString(.Username)
	}
	if .Flags.Has(2) {
		if .Photo == nil {
			return fmt.Errorf("unable to encode requestedPeerUser#d62ff46a: field photo is nil")
		}
		if  := .Photo.Encode();  != nil {
			return fmt.Errorf("unable to encode requestedPeerUser#d62ff46a: field photo: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RequestedPeerUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode requestedPeerUser#d62ff46a to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode requestedPeerUser#d62ff46a: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerUser#d62ff46a: field user_id: %w", )
		}
		.UserID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerUser#d62ff46a: field first_name: %w", )
		}
		.FirstName = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerUser#d62ff46a: field last_name: %w", )
		}
		.LastName = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerUser#d62ff46a: field username: %w", )
		}
		.Username = 
	}
	if .Flags.Has(2) {
		,  := DecodePhoto()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerUser#d62ff46a: field photo: %w", )
		}
		.Photo = 
	}
	return nil
}

// GetUserID returns value of UserID field.
func ( *RequestedPeerUser) () ( int64) {
	if  == nil {
		return
	}
	return .UserID
}

// SetFirstName sets value of FirstName conditional field.
func ( *RequestedPeerUser) ( string) {
	.Flags.Set(0)
	.FirstName = 
}

// GetFirstName returns value of FirstName conditional field and
// boolean which is true if field was set.
func ( *RequestedPeerUser) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .FirstName, true
}

// SetLastName sets value of LastName conditional field.
func ( *RequestedPeerUser) ( string) {
	.Flags.Set(0)
	.LastName = 
}

// GetLastName returns value of LastName conditional field and
// boolean which is true if field was set.
func ( *RequestedPeerUser) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .LastName, true
}

// SetUsername sets value of Username conditional field.
func ( *RequestedPeerUser) ( string) {
	.Flags.Set(1)
	.Username = 
}

// GetUsername returns value of Username conditional field and
// boolean which is true if field was set.
func ( *RequestedPeerUser) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Username, true
}

// SetPhoto sets value of Photo conditional field.
func ( *RequestedPeerUser) ( PhotoClass) {
	.Flags.Set(2)
	.Photo = 
}

// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func ( *RequestedPeerUser) () ( PhotoClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Photo, true
}

// RequestedPeerChat represents TL type `requestedPeerChat#7307544f`.
// Info about a chat¹, shared by a user with the currently logged in bot using messages
// sendBotRequestedPeer².
// All fields except the ID are optional, and will be populated if present on the chosen
// chat, according to the parameters of the requesting inputKeyboardButtonRequestPeer¹.
//
// Links:
//  1. https://core.telegram.org/api/channel
//  2. https://core.telegram.org/method/messages.sendBotRequestedPeer
//  3. https://core.telegram.org/constructor/inputKeyboardButtonRequestPeer
//
// See https://core.telegram.org/constructor/requestedPeerChat for reference.
type RequestedPeerChat struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Chat ID.
	ChatID int64
	// Chat title.
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// Chat photo.
	//
	// Use SetPhoto and GetPhoto helpers.
	Photo PhotoClass
}

// RequestedPeerChatTypeID is TL type id of RequestedPeerChat.
const RequestedPeerChatTypeID = 0x7307544f

// construct implements constructor of RequestedPeerClass.
func ( RequestedPeerChat) () RequestedPeerClass { return & }

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

	_ RequestedPeerClass = &RequestedPeerChat{}
)

func ( *RequestedPeerChat) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ChatID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}

	return true
}

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

// FillFrom fills RequestedPeerChat from given interface.
func ( *RequestedPeerChat) ( interface {
	() ( int64)
	() ( string,  bool)
	() ( PhotoClass,  bool)
}) {
	.ChatID = .()
	if ,  := .();  {
		.Title = 
	}

	if ,  := .();  {
		.Photo = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *RequestedPeerChat) () tdp.Type {
	 := tdp.Type{
		Name: "requestedPeerChat",
		ID:   RequestedPeerChatTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *RequestedPeerChat) () {
	if !(.Title == "") {
		.Flags.Set(0)
	}
	if !(.Photo == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *RequestedPeerChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestedPeerChat#7307544f as nil")
	}
	.PutID(RequestedPeerChatTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RequestedPeerChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestedPeerChat#7307544f as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode requestedPeerChat#7307544f: field flags: %w", )
	}
	.PutLong(.ChatID)
	if .Flags.Has(0) {
		.PutString(.Title)
	}
	if .Flags.Has(2) {
		if .Photo == nil {
			return fmt.Errorf("unable to encode requestedPeerChat#7307544f: field photo is nil")
		}
		if  := .Photo.Encode();  != nil {
			return fmt.Errorf("unable to encode requestedPeerChat#7307544f: field photo: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RequestedPeerChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode requestedPeerChat#7307544f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode requestedPeerChat#7307544f: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerChat#7307544f: field chat_id: %w", )
		}
		.ChatID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerChat#7307544f: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(2) {
		,  := DecodePhoto()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerChat#7307544f: field photo: %w", )
		}
		.Photo = 
	}
	return nil
}

// GetChatID returns value of ChatID field.
func ( *RequestedPeerChat) () ( int64) {
	if  == nil {
		return
	}
	return .ChatID
}

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

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

// SetPhoto sets value of Photo conditional field.
func ( *RequestedPeerChat) ( PhotoClass) {
	.Flags.Set(2)
	.Photo = 
}

// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func ( *RequestedPeerChat) () ( PhotoClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Photo, true
}

// RequestedPeerChannel represents TL type `requestedPeerChannel#8ba403e4`.
// Info about a channel/supergroup¹, shared by a user with the currently logged in bot
// using messages.sendBotRequestedPeer².
// All fields except the ID are optional, and will be populated if present on the chosen
// channel/supergroup, according to the parameters of the requesting
// inputKeyboardButtonRequestPeer¹.
//
// Links:
//  1. https://core.telegram.org/api/channel
//  2. https://core.telegram.org/method/messages.sendBotRequestedPeer
//  3. https://core.telegram.org/constructor/inputKeyboardButtonRequestPeer
//
// See https://core.telegram.org/constructor/requestedPeerChannel for reference.
type RequestedPeerChannel struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Channel/supergroup ID.
	ChannelID int64
	// Channel/supergroup title.
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// Channel/supergroup username.
	//
	// Use SetUsername and GetUsername helpers.
	Username string
	// Channel/supergroup photo.
	//
	// Use SetPhoto and GetPhoto helpers.
	Photo PhotoClass
}

// RequestedPeerChannelTypeID is TL type id of RequestedPeerChannel.
const RequestedPeerChannelTypeID = 0x8ba403e4

// construct implements constructor of RequestedPeerClass.
func ( RequestedPeerChannel) () RequestedPeerClass { return & }

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

	_ RequestedPeerClass = &RequestedPeerChannel{}
)

func ( *RequestedPeerChannel) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ChannelID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Username == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}

	return true
}

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

// FillFrom fills RequestedPeerChannel from given interface.
func ( *RequestedPeerChannel) ( interface {
	() ( int64)
	() ( string,  bool)
	() ( string,  bool)
	() ( PhotoClass,  bool)
}) {
	.ChannelID = .()
	if ,  := .();  {
		.Title = 
	}

	if ,  := .();  {
		.Username = 
	}

	if ,  := .();  {
		.Photo = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *RequestedPeerChannel) () tdp.Type {
	 := tdp.Type{
		Name: "requestedPeerChannel",
		ID:   RequestedPeerChannelTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChannelID",
			SchemaName: "channel_id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Username",
			SchemaName: "username",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *RequestedPeerChannel) () {
	if !(.Title == "") {
		.Flags.Set(0)
	}
	if !(.Username == "") {
		.Flags.Set(1)
	}
	if !(.Photo == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *RequestedPeerChannel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestedPeerChannel#8ba403e4 as nil")
	}
	.PutID(RequestedPeerChannelTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RequestedPeerChannel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestedPeerChannel#8ba403e4 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode requestedPeerChannel#8ba403e4: field flags: %w", )
	}
	.PutLong(.ChannelID)
	if .Flags.Has(0) {
		.PutString(.Title)
	}
	if .Flags.Has(1) {
		.PutString(.Username)
	}
	if .Flags.Has(2) {
		if .Photo == nil {
			return fmt.Errorf("unable to encode requestedPeerChannel#8ba403e4: field photo is nil")
		}
		if  := .Photo.Encode();  != nil {
			return fmt.Errorf("unable to encode requestedPeerChannel#8ba403e4: field photo: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RequestedPeerChannel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode requestedPeerChannel#8ba403e4 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode requestedPeerChannel#8ba403e4: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerChannel#8ba403e4: field channel_id: %w", )
		}
		.ChannelID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerChannel#8ba403e4: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerChannel#8ba403e4: field username: %w", )
		}
		.Username = 
	}
	if .Flags.Has(2) {
		,  := DecodePhoto()
		if  != nil {
			return fmt.Errorf("unable to decode requestedPeerChannel#8ba403e4: field photo: %w", )
		}
		.Photo = 
	}
	return nil
}

// GetChannelID returns value of ChannelID field.
func ( *RequestedPeerChannel) () ( int64) {
	if  == nil {
		return
	}
	return .ChannelID
}

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

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

// SetUsername sets value of Username conditional field.
func ( *RequestedPeerChannel) ( string) {
	.Flags.Set(1)
	.Username = 
}

// GetUsername returns value of Username conditional field and
// boolean which is true if field was set.
func ( *RequestedPeerChannel) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Username, true
}

// SetPhoto sets value of Photo conditional field.
func ( *RequestedPeerChannel) ( PhotoClass) {
	.Flags.Set(2)
	.Photo = 
}

// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func ( *RequestedPeerChannel) () ( PhotoClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Photo, true
}

// RequestedPeerClassName is schema name of RequestedPeerClass.
const RequestedPeerClassName = "RequestedPeer"

// RequestedPeerClass represents RequestedPeer generic type.
//
// See https://core.telegram.org/type/RequestedPeer for reference.
//
// Constructors:
//   - [RequestedPeerUser]
//   - [RequestedPeerChat]
//   - [RequestedPeerChannel]
//
// Example:
//
//	g, err := tg.DecodeRequestedPeer(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.RequestedPeerUser: // requestedPeerUser#d62ff46a
//	case *tg.RequestedPeerChat: // requestedPeerChat#7307544f
//	case *tg.RequestedPeerChannel: // requestedPeerChannel#8ba403e4
//	default: panic(v)
//	}
type RequestedPeerClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() RequestedPeerClass

	// 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

	// Profile photo.
	GetPhoto() (value PhotoClass, ok bool)
}

// DecodeRequestedPeer implements binary de-serialization for RequestedPeerClass.
func ( *bin.Buffer) (RequestedPeerClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case RequestedPeerUserTypeID:
		// Decoding requestedPeerUser#d62ff46a.
		 := RequestedPeerUser{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode RequestedPeerClass: %w", )
		}
		return &, nil
	case RequestedPeerChatTypeID:
		// Decoding requestedPeerChat#7307544f.
		 := RequestedPeerChat{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode RequestedPeerClass: %w", )
		}
		return &, nil
	case RequestedPeerChannelTypeID:
		// Decoding requestedPeerChannel#8ba403e4.
		 := RequestedPeerChannel{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode RequestedPeerClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode RequestedPeerClass: %w", bin.NewUnexpectedID())
	}
}

// RequestedPeer boxes the RequestedPeerClass providing a helper.
type RequestedPeerBox struct {
	RequestedPeer RequestedPeerClass
}

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

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