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

// RequestPeerTypeUser represents TL type `requestPeerTypeUser#5f3b8a00`.
// Choose a user.
//
// See https://core.telegram.org/constructor/requestPeerTypeUser for reference.
type RequestPeerTypeUser struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to allow choosing only bots.
	//
	// Use SetBot and GetBot helpers.
	Bot bool
	// Whether to allow choosing only PremiumĀ¹ users.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	//
	// Use SetPremium and GetPremium helpers.
	Premium bool
}

// RequestPeerTypeUserTypeID is TL type id of RequestPeerTypeUser.
const RequestPeerTypeUserTypeID = 0x5f3b8a00

// construct implements constructor of RequestPeerTypeClass.
func ( RequestPeerTypeUser) () RequestPeerTypeClass { return & }

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

	_ RequestPeerTypeClass = &RequestPeerTypeUser{}
)

func ( *RequestPeerTypeUser) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Bot == false) {
		return false
	}
	if !(.Premium == false) {
		return false
	}

	return true
}

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

// FillFrom fills RequestPeerTypeUser from given interface.
func ( *RequestPeerTypeUser) ( interface {
	() ( bool,  bool)
	() ( bool,  bool)
}) {
	if ,  := .();  {
		.Bot = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *RequestPeerTypeUser) () tdp.Type {
	 := tdp.Type{
		Name: "requestPeerTypeUser",
		ID:   RequestPeerTypeUserTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Bot",
			SchemaName: "bot",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Premium",
			SchemaName: "premium",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *RequestPeerTypeUser) () {
	if !(.Bot == false) {
		.Flags.Set(0)
	}
	if !(.Premium == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *RequestPeerTypeUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestPeerTypeUser#5f3b8a00 as nil")
	}
	.PutID(RequestPeerTypeUserTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RequestPeerTypeUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestPeerTypeUser#5f3b8a00 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode requestPeerTypeUser#5f3b8a00: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutBool(.Bot)
	}
	if .Flags.Has(1) {
		.PutBool(.Premium)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RequestPeerTypeUser) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode requestPeerTypeUser#5f3b8a00 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeUser#5f3b8a00: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeUser#5f3b8a00: field bot: %w", )
		}
		.Bot = 
	}
	if .Flags.Has(1) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeUser#5f3b8a00: field premium: %w", )
		}
		.Premium = 
	}
	return nil
}

// SetBot sets value of Bot conditional field.
func ( *RequestPeerTypeUser) ( bool) {
	.Flags.Set(0)
	.Bot = 
}

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

// SetPremium sets value of Premium conditional field.
func ( *RequestPeerTypeUser) ( bool) {
	.Flags.Set(1)
	.Premium = 
}

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

// RequestPeerTypeChat represents TL type `requestPeerTypeChat#c9f06e1b`.
// Choose a chat or supergroup
//
// See https://core.telegram.org/constructor/requestPeerTypeChat for reference.
type RequestPeerTypeChat struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to allow only choosing chats or supergroups that were created by the current
	// user.
	Creator bool
	// Whether to allow only choosing chats or supergroups where the bot is a participant.
	BotParticipant bool
	// If specified, allows only choosing channels with or without a username, according to
	// the value of BoolĀ¹.
	//
	// Links:
	//  1) https://core.telegram.org/type/Bool
	//
	// Use SetHasUsername and GetHasUsername helpers.
	HasUsername bool
	// If specified, allows only choosing chats or supergroups that are or aren't forumsĀ¹,
	// according to the value of BoolĀ².
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	//  2) https://core.telegram.org/type/Bool
	//
	// Use SetForum and GetForum helpers.
	Forum bool
	// If specified, allows only choosing chats or supergroups where the current user is an
	// admin with at least the specified admin rights.
	//
	// Use SetUserAdminRights and GetUserAdminRights helpers.
	UserAdminRights ChatAdminRights
	// If specified, allows only choosing chats or supergroups where the bot is an admin with
	// at least the specified admin rights.
	//
	// Use SetBotAdminRights and GetBotAdminRights helpers.
	BotAdminRights ChatAdminRights
}

// RequestPeerTypeChatTypeID is TL type id of RequestPeerTypeChat.
const RequestPeerTypeChatTypeID = 0xc9f06e1b

// construct implements constructor of RequestPeerTypeClass.
func ( RequestPeerTypeChat) () RequestPeerTypeClass { return & }

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

	_ RequestPeerTypeClass = &RequestPeerTypeChat{}
)

func ( *RequestPeerTypeChat) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Creator == false) {
		return false
	}
	if !(.BotParticipant == false) {
		return false
	}
	if !(.HasUsername == false) {
		return false
	}
	if !(.Forum == false) {
		return false
	}
	if !(.UserAdminRights.Zero()) {
		return false
	}
	if !(.BotAdminRights.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills RequestPeerTypeChat from given interface.
func ( *RequestPeerTypeChat) ( interface {
	() ( bool)
	() ( bool)
	() ( bool,  bool)
	() ( bool,  bool)
	() ( ChatAdminRights,  bool)
	() ( ChatAdminRights,  bool)
}) {
	.Creator = .()
	.BotParticipant = .()
	if ,  := .();  {
		.HasUsername = 
	}

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *RequestPeerTypeChat) () tdp.Type {
	 := tdp.Type{
		Name: "requestPeerTypeChat",
		ID:   RequestPeerTypeChatTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Creator",
			SchemaName: "creator",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "BotParticipant",
			SchemaName: "bot_participant",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "HasUsername",
			SchemaName: "has_username",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Forum",
			SchemaName: "forum",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "UserAdminRights",
			SchemaName: "user_admin_rights",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "BotAdminRights",
			SchemaName: "bot_admin_rights",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *RequestPeerTypeChat) () {
	if !(.Creator == false) {
		.Flags.Set(0)
	}
	if !(.BotParticipant == false) {
		.Flags.Set(5)
	}
	if !(.HasUsername == false) {
		.Flags.Set(3)
	}
	if !(.Forum == false) {
		.Flags.Set(4)
	}
	if !(.UserAdminRights.Zero()) {
		.Flags.Set(1)
	}
	if !(.BotAdminRights.Zero()) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *RequestPeerTypeChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestPeerTypeChat#c9f06e1b as nil")
	}
	.PutID(RequestPeerTypeChatTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RequestPeerTypeChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestPeerTypeChat#c9f06e1b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode requestPeerTypeChat#c9f06e1b: field flags: %w", )
	}
	if .Flags.Has(3) {
		.PutBool(.HasUsername)
	}
	if .Flags.Has(4) {
		.PutBool(.Forum)
	}
	if .Flags.Has(1) {
		if  := .UserAdminRights.Encode();  != nil {
			return fmt.Errorf("unable to encode requestPeerTypeChat#c9f06e1b: field user_admin_rights: %w", )
		}
	}
	if .Flags.Has(2) {
		if  := .BotAdminRights.Encode();  != nil {
			return fmt.Errorf("unable to encode requestPeerTypeChat#c9f06e1b: field bot_admin_rights: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RequestPeerTypeChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode requestPeerTypeChat#c9f06e1b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeChat#c9f06e1b: field flags: %w", )
		}
	}
	.Creator = .Flags.Has(0)
	.BotParticipant = .Flags.Has(5)
	if .Flags.Has(3) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeChat#c9f06e1b: field has_username: %w", )
		}
		.HasUsername = 
	}
	if .Flags.Has(4) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeChat#c9f06e1b: field forum: %w", )
		}
		.Forum = 
	}
	if .Flags.Has(1) {
		if  := .UserAdminRights.Decode();  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeChat#c9f06e1b: field user_admin_rights: %w", )
		}
	}
	if .Flags.Has(2) {
		if  := .BotAdminRights.Decode();  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeChat#c9f06e1b: field bot_admin_rights: %w", )
		}
	}
	return nil
}

// SetCreator sets value of Creator conditional field.
func ( *RequestPeerTypeChat) ( bool) {
	if  {
		.Flags.Set(0)
		.Creator = true
	} else {
		.Flags.Unset(0)
		.Creator = false
	}
}

// GetCreator returns value of Creator conditional field.
func ( *RequestPeerTypeChat) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetBotParticipant sets value of BotParticipant conditional field.
func ( *RequestPeerTypeChat) ( bool) {
	if  {
		.Flags.Set(5)
		.BotParticipant = true
	} else {
		.Flags.Unset(5)
		.BotParticipant = false
	}
}

// GetBotParticipant returns value of BotParticipant conditional field.
func ( *RequestPeerTypeChat) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetHasUsername sets value of HasUsername conditional field.
func ( *RequestPeerTypeChat) ( bool) {
	.Flags.Set(3)
	.HasUsername = 
}

// GetHasUsername returns value of HasUsername conditional field and
// boolean which is true if field was set.
func ( *RequestPeerTypeChat) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .HasUsername, true
}

// SetForum sets value of Forum conditional field.
func ( *RequestPeerTypeChat) ( bool) {
	.Flags.Set(4)
	.Forum = 
}

// GetForum returns value of Forum conditional field and
// boolean which is true if field was set.
func ( *RequestPeerTypeChat) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .Forum, true
}

// SetUserAdminRights sets value of UserAdminRights conditional field.
func ( *RequestPeerTypeChat) ( ChatAdminRights) {
	.Flags.Set(1)
	.UserAdminRights = 
}

// GetUserAdminRights returns value of UserAdminRights conditional field and
// boolean which is true if field was set.
func ( *RequestPeerTypeChat) () ( ChatAdminRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .UserAdminRights, true
}

// SetBotAdminRights sets value of BotAdminRights conditional field.
func ( *RequestPeerTypeChat) ( ChatAdminRights) {
	.Flags.Set(2)
	.BotAdminRights = 
}

// GetBotAdminRights returns value of BotAdminRights conditional field and
// boolean which is true if field was set.
func ( *RequestPeerTypeChat) () ( ChatAdminRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .BotAdminRights, true
}

// RequestPeerTypeBroadcast represents TL type `requestPeerTypeBroadcast#339bef6c`.
// Choose a channel
//
// See https://core.telegram.org/constructor/requestPeerTypeBroadcast for reference.
type RequestPeerTypeBroadcast struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to allow only choosing channels that were created by the current user.
	Creator bool
	// If specified, allows only choosing channels with or without a username, according to
	// the value of BoolĀ¹.
	//
	// Links:
	//  1) https://core.telegram.org/type/Bool
	//
	// Use SetHasUsername and GetHasUsername helpers.
	HasUsername bool
	// If specified, allows only choosing channels where the current user is an admin with at
	// least the specified admin rights.
	//
	// Use SetUserAdminRights and GetUserAdminRights helpers.
	UserAdminRights ChatAdminRights
	// If specified, allows only choosing channels where the bot is an admin with at least
	// the specified admin rights.
	//
	// Use SetBotAdminRights and GetBotAdminRights helpers.
	BotAdminRights ChatAdminRights
}

// RequestPeerTypeBroadcastTypeID is TL type id of RequestPeerTypeBroadcast.
const RequestPeerTypeBroadcastTypeID = 0x339bef6c

// construct implements constructor of RequestPeerTypeClass.
func ( RequestPeerTypeBroadcast) () RequestPeerTypeClass { return & }

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

	_ RequestPeerTypeClass = &RequestPeerTypeBroadcast{}
)

func ( *RequestPeerTypeBroadcast) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Creator == false) {
		return false
	}
	if !(.HasUsername == false) {
		return false
	}
	if !(.UserAdminRights.Zero()) {
		return false
	}
	if !(.BotAdminRights.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills RequestPeerTypeBroadcast from given interface.
func ( *RequestPeerTypeBroadcast) ( interface {
	() ( bool)
	() ( bool,  bool)
	() ( ChatAdminRights,  bool)
	() ( ChatAdminRights,  bool)
}) {
	.Creator = .()
	if ,  := .();  {
		.HasUsername = 
	}

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *RequestPeerTypeBroadcast) () tdp.Type {
	 := tdp.Type{
		Name: "requestPeerTypeBroadcast",
		ID:   RequestPeerTypeBroadcastTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Creator",
			SchemaName: "creator",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "HasUsername",
			SchemaName: "has_username",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "UserAdminRights",
			SchemaName: "user_admin_rights",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "BotAdminRights",
			SchemaName: "bot_admin_rights",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *RequestPeerTypeBroadcast) () {
	if !(.Creator == false) {
		.Flags.Set(0)
	}
	if !(.HasUsername == false) {
		.Flags.Set(3)
	}
	if !(.UserAdminRights.Zero()) {
		.Flags.Set(1)
	}
	if !(.BotAdminRights.Zero()) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *RequestPeerTypeBroadcast) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestPeerTypeBroadcast#339bef6c as nil")
	}
	.PutID(RequestPeerTypeBroadcastTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RequestPeerTypeBroadcast) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode requestPeerTypeBroadcast#339bef6c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode requestPeerTypeBroadcast#339bef6c: field flags: %w", )
	}
	if .Flags.Has(3) {
		.PutBool(.HasUsername)
	}
	if .Flags.Has(1) {
		if  := .UserAdminRights.Encode();  != nil {
			return fmt.Errorf("unable to encode requestPeerTypeBroadcast#339bef6c: field user_admin_rights: %w", )
		}
	}
	if .Flags.Has(2) {
		if  := .BotAdminRights.Encode();  != nil {
			return fmt.Errorf("unable to encode requestPeerTypeBroadcast#339bef6c: field bot_admin_rights: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RequestPeerTypeBroadcast) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode requestPeerTypeBroadcast#339bef6c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeBroadcast#339bef6c: field flags: %w", )
		}
	}
	.Creator = .Flags.Has(0)
	if .Flags.Has(3) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeBroadcast#339bef6c: field has_username: %w", )
		}
		.HasUsername = 
	}
	if .Flags.Has(1) {
		if  := .UserAdminRights.Decode();  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeBroadcast#339bef6c: field user_admin_rights: %w", )
		}
	}
	if .Flags.Has(2) {
		if  := .BotAdminRights.Decode();  != nil {
			return fmt.Errorf("unable to decode requestPeerTypeBroadcast#339bef6c: field bot_admin_rights: %w", )
		}
	}
	return nil
}

// SetCreator sets value of Creator conditional field.
func ( *RequestPeerTypeBroadcast) ( bool) {
	if  {
		.Flags.Set(0)
		.Creator = true
	} else {
		.Flags.Unset(0)
		.Creator = false
	}
}

// GetCreator returns value of Creator conditional field.
func ( *RequestPeerTypeBroadcast) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetHasUsername sets value of HasUsername conditional field.
func ( *RequestPeerTypeBroadcast) ( bool) {
	.Flags.Set(3)
	.HasUsername = 
}

// GetHasUsername returns value of HasUsername conditional field and
// boolean which is true if field was set.
func ( *RequestPeerTypeBroadcast) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .HasUsername, true
}

// SetUserAdminRights sets value of UserAdminRights conditional field.
func ( *RequestPeerTypeBroadcast) ( ChatAdminRights) {
	.Flags.Set(1)
	.UserAdminRights = 
}

// GetUserAdminRights returns value of UserAdminRights conditional field and
// boolean which is true if field was set.
func ( *RequestPeerTypeBroadcast) () ( ChatAdminRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .UserAdminRights, true
}

// SetBotAdminRights sets value of BotAdminRights conditional field.
func ( *RequestPeerTypeBroadcast) ( ChatAdminRights) {
	.Flags.Set(2)
	.BotAdminRights = 
}

// GetBotAdminRights returns value of BotAdminRights conditional field and
// boolean which is true if field was set.
func ( *RequestPeerTypeBroadcast) () ( ChatAdminRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .BotAdminRights, true
}

// RequestPeerTypeClassName is schema name of RequestPeerTypeClass.
const RequestPeerTypeClassName = "RequestPeerType"

// RequestPeerTypeClass represents RequestPeerType generic type.
//
// See https://core.telegram.org/type/RequestPeerType for reference.
//
// Example:
//
//	g, err := tg.DecodeRequestPeerType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.RequestPeerTypeUser: // requestPeerTypeUser#5f3b8a00
//	case *tg.RequestPeerTypeChat: // requestPeerTypeChat#c9f06e1b
//	case *tg.RequestPeerTypeBroadcast: // requestPeerTypeBroadcast#339bef6c
//	default: panic(v)
//	}
type RequestPeerTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() RequestPeerTypeClass

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

// DecodeRequestPeerType implements binary de-serialization for RequestPeerTypeClass.
func ( *bin.Buffer) (RequestPeerTypeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case RequestPeerTypeUserTypeID:
		// Decoding requestPeerTypeUser#5f3b8a00.
		 := RequestPeerTypeUser{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode RequestPeerTypeClass: %w", )
		}
		return &, nil
	case RequestPeerTypeChatTypeID:
		// Decoding requestPeerTypeChat#c9f06e1b.
		 := RequestPeerTypeChat{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode RequestPeerTypeClass: %w", )
		}
		return &, nil
	case RequestPeerTypeBroadcastTypeID:
		// Decoding requestPeerTypeBroadcast#339bef6c.
		 := RequestPeerTypeBroadcast{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode RequestPeerTypeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode RequestPeerTypeClass: %w", bin.NewUnexpectedID())
	}
}

// RequestPeerType boxes the RequestPeerTypeClass providing a helper.
type RequestPeerTypeBox struct {
	RequestPeerType RequestPeerTypeClass
}

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

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