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

// StatsPercentValue represents TL type `statsPercentValue#cbce2fe0`.
// Channel statistics percentage¹.
// Compute the percentage simply by doing part * total / 100
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// See https://core.telegram.org/constructor/statsPercentValue for reference.
type StatsPercentValue struct {
	// Partial value
	Part float64
	// Total value
	Total float64
}

// StatsPercentValueTypeID is TL type id of StatsPercentValue.
const StatsPercentValueTypeID = 0xcbce2fe0

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

func ( *StatsPercentValue) () bool {
	if  == nil {
		return true
	}
	if !(.Part == 0) {
		return false
	}
	if !(.Total == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StatsPercentValue from given interface.
func ( *StatsPercentValue) ( interface {
	() ( float64)
	() ( float64)
}) {
	.Part = .()
	.Total = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StatsPercentValue) () tdp.Type {
	 := tdp.Type{
		Name: "statsPercentValue",
		ID:   StatsPercentValueTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Part",
			SchemaName: "part",
		},
		{
			Name:       "Total",
			SchemaName: "total",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StatsPercentValue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode statsPercentValue#cbce2fe0 as nil")
	}
	.PutID(StatsPercentValueTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsPercentValue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode statsPercentValue#cbce2fe0 as nil")
	}
	.PutDouble(.Part)
	.PutDouble(.Total)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StatsPercentValue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode statsPercentValue#cbce2fe0 to nil")
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode statsPercentValue#cbce2fe0: field part: %w", )
		}
		.Part = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode statsPercentValue#cbce2fe0: field total: %w", )
		}
		.Total = 
	}
	return nil
}

// GetPart returns value of Part field.
func ( *StatsPercentValue) () ( float64) {
	if  == nil {
		return
	}
	return .Part
}

// GetTotal returns value of Total field.
func ( *StatsPercentValue) () ( float64) {
	if  == nil {
		return
	}
	return .Total
}