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

// MessagePeerVote represents TL type `messagePeerVote#b6cc2d5c`.
// How a peer voted in a poll
//
// See https://core.telegram.org/constructor/messagePeerVote for reference.
type MessagePeerVote struct {
	// Peer ID
	Peer PeerClass
	// The option chosen by the peer
	Option []byte
	// When did the peer cast the vote
	Date int
}

// MessagePeerVoteTypeID is TL type id of MessagePeerVote.
const MessagePeerVoteTypeID = 0xb6cc2d5c

// construct implements constructor of MessagePeerVoteClass.
func ( MessagePeerVote) () MessagePeerVoteClass { return & }

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

	_ MessagePeerVoteClass = &MessagePeerVote{}
)

func ( *MessagePeerVote) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Option == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagePeerVote from given interface.
func ( *MessagePeerVote) ( interface {
	() ( PeerClass)
	() ( []byte)
	() ( int)
}) {
	.Peer = .()
	.Option = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagePeerVote) () tdp.Type {
	 := tdp.Type{
		Name: "messagePeerVote",
		ID:   MessagePeerVoteTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Option",
			SchemaName: "option",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagePeerVote) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messagePeerVote#b6cc2d5c as nil")
	}
	.PutID(MessagePeerVoteTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagePeerVote) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messagePeerVote#b6cc2d5c to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerVote#b6cc2d5c: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerVote#b6cc2d5c: field option: %w", )
		}
		.Option = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerVote#b6cc2d5c: field date: %w", )
		}
		.Date = 
	}
	return nil
}

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

// GetOption returns value of Option field.
func ( *MessagePeerVote) () ( []byte) {
	if  == nil {
		return
	}
	return .Option
}

// GetDate returns value of Date field.
func ( *MessagePeerVote) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// MessagePeerVoteInputOption represents TL type `messagePeerVoteInputOption#74cda504`.
// How a peer voted in a poll (reduced constructor, returned if an option was provided to
// messages.getPollVotesĀ¹)
//
// Links:
//  1. https://core.telegram.org/method/messages.getPollVotes
//
// See https://core.telegram.org/constructor/messagePeerVoteInputOption for reference.
type MessagePeerVoteInputOption struct {
	// The peer that voted for the queried option
	Peer PeerClass
	// When did the peer cast the vote
	Date int
}

// MessagePeerVoteInputOptionTypeID is TL type id of MessagePeerVoteInputOption.
const MessagePeerVoteInputOptionTypeID = 0x74cda504

// construct implements constructor of MessagePeerVoteClass.
func ( MessagePeerVoteInputOption) () MessagePeerVoteClass { return & }

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

	_ MessagePeerVoteClass = &MessagePeerVoteInputOption{}
)

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *MessagePeerVoteInputOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messagePeerVoteInputOption#74cda504 as nil")
	}
	.PutID(MessagePeerVoteInputOptionTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagePeerVoteInputOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messagePeerVoteInputOption#74cda504 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerVoteInputOption#74cda504: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerVoteInputOption#74cda504: field date: %w", )
		}
		.Date = 
	}
	return nil
}

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

// GetDate returns value of Date field.
func ( *MessagePeerVoteInputOption) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// MessagePeerVoteMultiple represents TL type `messagePeerVoteMultiple#4628f6e6`.
// How a peer voted in a multiple-choice poll
//
// See https://core.telegram.org/constructor/messagePeerVoteMultiple for reference.
type MessagePeerVoteMultiple struct {
	// Peer ID
	Peer PeerClass
	// Options chosen by the peer
	Options [][]byte
	// When did the peer cast their votes
	Date int
}

// MessagePeerVoteMultipleTypeID is TL type id of MessagePeerVoteMultiple.
const MessagePeerVoteMultipleTypeID = 0x4628f6e6

// construct implements constructor of MessagePeerVoteClass.
func ( MessagePeerVoteMultiple) () MessagePeerVoteClass { return & }

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

	_ MessagePeerVoteClass = &MessagePeerVoteMultiple{}
)

func ( *MessagePeerVoteMultiple) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Options == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagePeerVoteMultiple from given interface.
func ( *MessagePeerVoteMultiple) ( interface {
	() ( PeerClass)
	() ( [][]byte)
	() ( int)
}) {
	.Peer = .()
	.Options = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagePeerVoteMultiple) () tdp.Type {
	 := tdp.Type{
		Name: "messagePeerVoteMultiple",
		ID:   MessagePeerVoteMultipleTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Options",
			SchemaName: "options",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagePeerVoteMultiple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messagePeerVoteMultiple#4628f6e6 as nil")
	}
	.PutID(MessagePeerVoteMultipleTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagePeerVoteMultiple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messagePeerVoteMultiple#4628f6e6 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messagePeerVoteMultiple#4628f6e6: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messagePeerVoteMultiple#4628f6e6: field peer: %w", )
	}
	.PutVectorHeader(len(.Options))
	for ,  := range .Options {
		.PutBytes()
	}
	.PutInt(.Date)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagePeerVoteMultiple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messagePeerVoteMultiple#4628f6e6 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerVoteMultiple#4628f6e6: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerVoteMultiple#4628f6e6: field options: %w", )
		}

		if  > 0 {
			.Options = make([][]byte, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Bytes()
			if  != nil {
				return fmt.Errorf("unable to decode messagePeerVoteMultiple#4628f6e6: field options: %w", )
			}
			.Options = append(.Options, )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerVoteMultiple#4628f6e6: field date: %w", )
		}
		.Date = 
	}
	return nil
}

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

// GetOptions returns value of Options field.
func ( *MessagePeerVoteMultiple) () ( [][]byte) {
	if  == nil {
		return
	}
	return .Options
}

// GetDate returns value of Date field.
func ( *MessagePeerVoteMultiple) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// MessagePeerVoteClassName is schema name of MessagePeerVoteClass.
const MessagePeerVoteClassName = "MessagePeerVote"

// MessagePeerVoteClass represents MessagePeerVote generic type.
//
// See https://core.telegram.org/type/MessagePeerVote for reference.
//
// Example:
//
//	g, err := tg.DecodeMessagePeerVote(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessagePeerVote: // messagePeerVote#b6cc2d5c
//	case *tg.MessagePeerVoteInputOption: // messagePeerVoteInputOption#74cda504
//	case *tg.MessagePeerVoteMultiple: // messagePeerVoteMultiple#4628f6e6
//	default: panic(v)
//	}
type MessagePeerVoteClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagePeerVoteClass

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

	// Peer ID
	GetPeer() (value PeerClass)

	// When did the peer cast the vote
	GetDate() (value int)
}

// DecodeMessagePeerVote implements binary de-serialization for MessagePeerVoteClass.
func ( *bin.Buffer) (MessagePeerVoteClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessagePeerVoteTypeID:
		// Decoding messagePeerVote#b6cc2d5c.
		 := MessagePeerVote{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagePeerVoteClass: %w", )
		}
		return &, nil
	case MessagePeerVoteInputOptionTypeID:
		// Decoding messagePeerVoteInputOption#74cda504.
		 := MessagePeerVoteInputOption{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagePeerVoteClass: %w", )
		}
		return &, nil
	case MessagePeerVoteMultipleTypeID:
		// Decoding messagePeerVoteMultiple#4628f6e6.
		 := MessagePeerVoteMultiple{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagePeerVoteClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessagePeerVoteClass: %w", bin.NewUnexpectedID())
	}
}

// MessagePeerVote boxes the MessagePeerVoteClass providing a helper.
type MessagePeerVoteBox struct {
	MessagePeerVote MessagePeerVoteClass
}

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

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