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

// PollAnswerVoters represents TL type `pollAnswerVoters#3b6ddad2`.
// A poll answer, and how users voted on it
//
// See https://core.telegram.org/constructor/pollAnswerVoters for reference.
type PollAnswerVoters struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether we have chosen this answer
	Chosen bool
	// For quizzes, whether the option we have chosen is correct
	Correct bool
	// The param that has to be passed to messages.sendVoteĀ¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.sendVote
	Option []byte
	// How many users voted for this option
	Voters int
}

// PollAnswerVotersTypeID is TL type id of PollAnswerVoters.
const PollAnswerVotersTypeID = 0x3b6ddad2

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

func ( *PollAnswerVoters) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Chosen == false) {
		return false
	}
	if !(.Correct == false) {
		return false
	}
	if !(.Option == nil) {
		return false
	}
	if !(.Voters == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PollAnswerVoters from given interface.
func ( *PollAnswerVoters) ( interface {
	() ( bool)
	() ( bool)
	() ( []byte)
	() ( int)
}) {
	.Chosen = .()
	.Correct = .()
	.Option = .()
	.Voters = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PollAnswerVoters) () tdp.Type {
	 := tdp.Type{
		Name: "pollAnswerVoters",
		ID:   PollAnswerVotersTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Chosen",
			SchemaName: "chosen",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Correct",
			SchemaName: "correct",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Option",
			SchemaName: "option",
		},
		{
			Name:       "Voters",
			SchemaName: "voters",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *PollAnswerVoters) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pollAnswerVoters#3b6ddad2 as nil")
	}
	.PutID(PollAnswerVotersTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PollAnswerVoters) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pollAnswerVoters#3b6ddad2 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode pollAnswerVoters#3b6ddad2: field flags: %w", )
	}
	.PutBytes(.Option)
	.PutInt(.Voters)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PollAnswerVoters) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode pollAnswerVoters#3b6ddad2 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode pollAnswerVoters#3b6ddad2: field flags: %w", )
		}
	}
	.Chosen = .Flags.Has(0)
	.Correct = .Flags.Has(1)
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode pollAnswerVoters#3b6ddad2: field option: %w", )
		}
		.Option = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode pollAnswerVoters#3b6ddad2: field voters: %w", )
		}
		.Voters = 
	}
	return nil
}

// SetChosen sets value of Chosen conditional field.
func ( *PollAnswerVoters) ( bool) {
	if  {
		.Flags.Set(0)
		.Chosen = true
	} else {
		.Flags.Unset(0)
		.Chosen = false
	}
}

// GetChosen returns value of Chosen conditional field.
func ( *PollAnswerVoters) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetCorrect sets value of Correct conditional field.
func ( *PollAnswerVoters) ( bool) {
	if  {
		.Flags.Set(1)
		.Correct = true
	} else {
		.Flags.Unset(1)
		.Correct = false
	}
}

// GetCorrect returns value of Correct conditional field.
func ( *PollAnswerVoters) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// GetVoters returns value of Voters field.
func ( *PollAnswerVoters) () ( int) {
	if  == nil {
		return
	}
	return .Voters
}