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

// StarGiftActiveAuctionState represents TL type `starGiftActiveAuctionState#d31bc45d`.
// Contains info about an auction where the user has placed a bid »¹.
//
// Links:
//  1. https://core.telegram.org/api/auctions
//
// See https://core.telegram.org/constructor/starGiftActiveAuctionState for reference.
type StarGiftActiveAuctionState struct {
	// The collectible gift »¹ currently being distributed in the auction.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	Gift StarGiftClass
	// Auction state
	State StarGiftAuctionStateClass
	// Auction state related to the current user (i.e. info about placed bids, won gifts and
	// so on).
	UserState StarGiftAuctionUserState
}

// StarGiftActiveAuctionStateTypeID is TL type id of StarGiftActiveAuctionState.
const StarGiftActiveAuctionStateTypeID = 0xd31bc45d

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

func ( *StarGiftActiveAuctionState) () bool {
	if  == nil {
		return true
	}
	if !(.Gift == nil) {
		return false
	}
	if !(.State == nil) {
		return false
	}
	if !(.UserState.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftActiveAuctionState from given interface.
func ( *StarGiftActiveAuctionState) ( interface {
	() ( StarGiftClass)
	() ( StarGiftAuctionStateClass)
	() ( StarGiftAuctionUserState)
}) {
	.Gift = .()
	.State = .()
	.UserState = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftActiveAuctionState) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftActiveAuctionState",
		ID:   StarGiftActiveAuctionStateTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
		{
			Name:       "State",
			SchemaName: "state",
		},
		{
			Name:       "UserState",
			SchemaName: "user_state",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftActiveAuctionState) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftActiveAuctionState#d31bc45d as nil")
	}
	.PutID(StarGiftActiveAuctionStateTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftActiveAuctionState) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftActiveAuctionState#d31bc45d as nil")
	}
	if .Gift == nil {
		return fmt.Errorf("unable to encode starGiftActiveAuctionState#d31bc45d: field gift is nil")
	}
	if  := .Gift.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftActiveAuctionState#d31bc45d: field gift: %w", )
	}
	if .State == nil {
		return fmt.Errorf("unable to encode starGiftActiveAuctionState#d31bc45d: field state is nil")
	}
	if  := .State.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftActiveAuctionState#d31bc45d: field state: %w", )
	}
	if  := .UserState.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftActiveAuctionState#d31bc45d: field user_state: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftActiveAuctionState) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftActiveAuctionState#d31bc45d to nil")
	}
	{
		,  := DecodeStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftActiveAuctionState#d31bc45d: field gift: %w", )
		}
		.Gift = 
	}
	{
		,  := DecodeStarGiftAuctionState()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftActiveAuctionState#d31bc45d: field state: %w", )
		}
		.State = 
	}
	{
		if  := .UserState.Decode();  != nil {
			return fmt.Errorf("unable to decode starGiftActiveAuctionState#d31bc45d: field user_state: %w", )
		}
	}
	return nil
}

// GetGift returns value of Gift field.
func ( *StarGiftActiveAuctionState) () ( StarGiftClass) {
	if  == nil {
		return
	}
	return .Gift
}

// GetState returns value of State field.
func ( *StarGiftActiveAuctionState) () ( StarGiftAuctionStateClass) {
	if  == nil {
		return
	}
	return .State
}

// GetUserState returns value of UserState field.
func ( *StarGiftActiveAuctionState) () ( StarGiftAuctionUserState) {
	if  == nil {
		return
	}
	return .UserState
}

// GetStateAsModified returns mapped value of State field.
func ( *StarGiftActiveAuctionState) () (ModifiedStarGiftAuctionState, bool) {
	return .State.AsModified()
}