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

// StatsAbsValueAndPrev represents TL type `statsAbsValueAndPrev#cb43acde`.
// Statistics value couple; initial and final value for period of time currently in
// consideration
//
// See https://core.telegram.org/constructor/statsAbsValueAndPrev for reference.
type StatsAbsValueAndPrev struct {
	// Current value
	Current float64
	// Previous value
	Previous float64
}

// StatsAbsValueAndPrevTypeID is TL type id of StatsAbsValueAndPrev.
const StatsAbsValueAndPrevTypeID = 0xcb43acde

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

func ( *StatsAbsValueAndPrev) () bool {
	if  == nil {
		return true
	}
	if !(.Current == 0) {
		return false
	}
	if !(.Previous == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StatsAbsValueAndPrev from given interface.
func ( *StatsAbsValueAndPrev) ( interface {
	() ( float64)
	() ( float64)
}) {
	.Current = .()
	.Previous = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StatsAbsValueAndPrev) () tdp.Type {
	 := tdp.Type{
		Name: "statsAbsValueAndPrev",
		ID:   StatsAbsValueAndPrevTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Current",
			SchemaName: "current",
		},
		{
			Name:       "Previous",
			SchemaName: "previous",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StatsAbsValueAndPrev) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode statsAbsValueAndPrev#cb43acde as nil")
	}
	.PutID(StatsAbsValueAndPrevTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsAbsValueAndPrev) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode statsAbsValueAndPrev#cb43acde as nil")
	}
	.PutDouble(.Current)
	.PutDouble(.Previous)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StatsAbsValueAndPrev) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode statsAbsValueAndPrev#cb43acde to nil")
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode statsAbsValueAndPrev#cb43acde: field current: %w", )
		}
		.Current = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode statsAbsValueAndPrev#cb43acde: field previous: %w", )
		}
		.Previous = 
	}
	return nil
}

// GetCurrent returns value of Current field.
func ( *StatsAbsValueAndPrev) () ( float64) {
	if  == nil {
		return
	}
	return .Current
}

// GetPrevious returns value of Previous field.
func ( *StatsAbsValueAndPrev) () ( float64) {
	if  == nil {
		return
	}
	return .Previous
}