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

// NotifyPeer represents TL type `notifyPeer#9fd40bd8`.
// Notifications generated by a certain user or group.
//
// See https://core.telegram.org/constructor/notifyPeer for reference.
type NotifyPeer struct {
	// user or group
	Peer PeerClass
}

// NotifyPeerTypeID is TL type id of NotifyPeer.
const NotifyPeerTypeID = 0x9fd40bd8

// construct implements constructor of NotifyPeerClass.
func ( NotifyPeer) () NotifyPeerClass { return & }

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

	_ NotifyPeerClass = &NotifyPeer{}
)

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *NotifyPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode notifyPeer#9fd40bd8 as nil")
	}
	.PutID(NotifyPeerTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *NotifyPeer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode notifyPeer#9fd40bd8 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode notifyPeer#9fd40bd8: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

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

// NotifyUsers represents TL type `notifyUsers#b4c83b4c`.
// Notifications generated by all users.
//
// See https://core.telegram.org/constructor/notifyUsers for reference.
type NotifyUsers struct {
}

// NotifyUsersTypeID is TL type id of NotifyUsers.
const NotifyUsersTypeID = 0xb4c83b4c

// construct implements constructor of NotifyPeerClass.
func ( NotifyUsers) () NotifyPeerClass { return & }

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

	_ NotifyPeerClass = &NotifyUsers{}
)

func ( *NotifyUsers) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *NotifyUsers) () tdp.Type {
	 := tdp.Type{
		Name: "notifyUsers",
		ID:   NotifyUsersTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *NotifyUsers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode notifyUsers#b4c83b4c as nil")
	}
	.PutID(NotifyUsersTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *NotifyUsers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode notifyUsers#b4c83b4c as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *NotifyUsers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode notifyUsers#b4c83b4c to nil")
	}
	return nil
}

// NotifyChats represents TL type `notifyChats#c007cec3`.
// Notifications generated by all groups.
//
// See https://core.telegram.org/constructor/notifyChats for reference.
type NotifyChats struct {
}

// NotifyChatsTypeID is TL type id of NotifyChats.
const NotifyChatsTypeID = 0xc007cec3

// construct implements constructor of NotifyPeerClass.
func ( NotifyChats) () NotifyPeerClass { return & }

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

	_ NotifyPeerClass = &NotifyChats{}
)

func ( *NotifyChats) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *NotifyChats) () tdp.Type {
	 := tdp.Type{
		Name: "notifyChats",
		ID:   NotifyChatsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *NotifyChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode notifyChats#c007cec3 as nil")
	}
	.PutID(NotifyChatsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *NotifyChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode notifyChats#c007cec3 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *NotifyChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode notifyChats#c007cec3 to nil")
	}
	return nil
}

// NotifyBroadcasts represents TL type `notifyBroadcasts#d612e8ef`.
// Channel notification settings
//
// See https://core.telegram.org/constructor/notifyBroadcasts for reference.
type NotifyBroadcasts struct {
}

// NotifyBroadcastsTypeID is TL type id of NotifyBroadcasts.
const NotifyBroadcastsTypeID = 0xd612e8ef

// construct implements constructor of NotifyPeerClass.
func ( NotifyBroadcasts) () NotifyPeerClass { return & }

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

	_ NotifyPeerClass = &NotifyBroadcasts{}
)

func ( *NotifyBroadcasts) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *NotifyBroadcasts) () tdp.Type {
	 := tdp.Type{
		Name: "notifyBroadcasts",
		ID:   NotifyBroadcastsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *NotifyBroadcasts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode notifyBroadcasts#d612e8ef as nil")
	}
	.PutID(NotifyBroadcastsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *NotifyBroadcasts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode notifyBroadcasts#d612e8ef as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *NotifyBroadcasts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode notifyBroadcasts#d612e8ef to nil")
	}
	return nil
}

// NotifyForumTopic represents TL type `notifyForumTopic#226e6308`.
// Notifications generated by a topic¹ in a forum².
//
// Links:
//  1. https://core.telegram.org/api/forum#forum-topics
//  2. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/constructor/notifyForumTopic for reference.
type NotifyForumTopic struct {
	// Forum ID
	Peer PeerClass
	// Topic ID¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum#forum-topics
	TopMsgID int
}

// NotifyForumTopicTypeID is TL type id of NotifyForumTopic.
const NotifyForumTopicTypeID = 0x226e6308

// construct implements constructor of NotifyPeerClass.
func ( NotifyForumTopic) () NotifyPeerClass { return & }

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

	_ NotifyPeerClass = &NotifyForumTopic{}
)

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

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *NotifyForumTopic) () tdp.Type {
	 := tdp.Type{
		Name: "notifyForumTopic",
		ID:   NotifyForumTopicTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "TopMsgID",
			SchemaName: "top_msg_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *NotifyForumTopic) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode notifyForumTopic#226e6308 as nil")
	}
	.PutID(NotifyForumTopicTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *NotifyForumTopic) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode notifyForumTopic#226e6308 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode notifyForumTopic#226e6308: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode notifyForumTopic#226e6308: field top_msg_id: %w", )
		}
		.TopMsgID = 
	}
	return nil
}

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

// GetTopMsgID returns value of TopMsgID field.
func ( *NotifyForumTopic) () ( int) {
	if  == nil {
		return
	}
	return .TopMsgID
}

// NotifyPeerClassName is schema name of NotifyPeerClass.
const NotifyPeerClassName = "NotifyPeer"

// NotifyPeerClass represents NotifyPeer generic type.
//
// See https://core.telegram.org/type/NotifyPeer for reference.
//
// Example:
//
//	g, err := tg.DecodeNotifyPeer(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.NotifyPeer: // notifyPeer#9fd40bd8
//	case *tg.NotifyUsers: // notifyUsers#b4c83b4c
//	case *tg.NotifyChats: // notifyChats#c007cec3
//	case *tg.NotifyBroadcasts: // notifyBroadcasts#d612e8ef
//	case *tg.NotifyForumTopic: // notifyForumTopic#226e6308
//	default: panic(v)
//	}
type NotifyPeerClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() NotifyPeerClass

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

// DecodeNotifyPeer implements binary de-serialization for NotifyPeerClass.
func ( *bin.Buffer) (NotifyPeerClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case NotifyPeerTypeID:
		// Decoding notifyPeer#9fd40bd8.
		 := NotifyPeer{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", )
		}
		return &, nil
	case NotifyUsersTypeID:
		// Decoding notifyUsers#b4c83b4c.
		 := NotifyUsers{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", )
		}
		return &, nil
	case NotifyChatsTypeID:
		// Decoding notifyChats#c007cec3.
		 := NotifyChats{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", )
		}
		return &, nil
	case NotifyBroadcastsTypeID:
		// Decoding notifyBroadcasts#d612e8ef.
		 := NotifyBroadcasts{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", )
		}
		return &, nil
	case NotifyForumTopicTypeID:
		// Decoding notifyForumTopic#226e6308.
		 := NotifyForumTopic{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode NotifyPeerClass: %w", bin.NewUnexpectedID())
	}
}

// NotifyPeer boxes the NotifyPeerClass providing a helper.
type NotifyPeerBox struct {
	NotifyPeer NotifyPeerClass
}

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

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