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

// MyBoost represents TL type `myBoost#c448415c`.
// Contains information about a single boost slot »¹.
//
// Links:
//  1. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/constructor/myBoost for reference.
type MyBoost struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Boost slot ID »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	Slot int
	// If set, indicates this slot is currently occupied, i.e. we are boosting¹ this peer.
	// Note that we can assign multiple boost slots to the same peer.
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	//
	// Use SetPeer and GetPeer helpers.
	Peer PeerClass
	// When (unixtime) we started boosting the peer, 0 otherwise.
	Date int
	// Indicates the (unixtime) expiration date of the boost in peer (0 if peer is not set).
	Expires int
	// If peer is set, indicates the (unixtime) date after which this boost can be reassigned
	// to another channel.
	//
	// Use SetCooldownUntilDate and GetCooldownUntilDate helpers.
	CooldownUntilDate int
}

// MyBoostTypeID is TL type id of MyBoost.
const MyBoostTypeID = 0xc448415c

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

func ( *MyBoost) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Slot == 0) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Expires == 0) {
		return false
	}
	if !(.CooldownUntilDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MyBoost from given interface.
func ( *MyBoost) ( interface {
	() ( int)
	() ( PeerClass,  bool)
	() ( int)
	() ( int)
	() ( int,  bool)
}) {
	.Slot = .()
	if ,  := .();  {
		.Peer = 
	}

	.Date = .()
	.Expires = .()
	if ,  := .();  {
		.CooldownUntilDate = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MyBoost) () tdp.Type {
	 := tdp.Type{
		Name: "myBoost",
		ID:   MyBoostTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Slot",
			SchemaName: "slot",
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Expires",
			SchemaName: "expires",
		},
		{
			Name:       "CooldownUntilDate",
			SchemaName: "cooldown_until_date",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MyBoost) () {
	if !(.Peer == nil) {
		.Flags.Set(0)
	}
	if !(.CooldownUntilDate == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MyBoost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode myBoost#c448415c as nil")
	}
	.PutID(MyBoostTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MyBoost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode myBoost#c448415c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode myBoost#c448415c: field flags: %w", )
	}
	.PutInt(.Slot)
	if .Flags.Has(0) {
		if .Peer == nil {
			return fmt.Errorf("unable to encode myBoost#c448415c: field peer is nil")
		}
		if  := .Peer.Encode();  != nil {
			return fmt.Errorf("unable to encode myBoost#c448415c: field peer: %w", )
		}
	}
	.PutInt(.Date)
	.PutInt(.Expires)
	if .Flags.Has(1) {
		.PutInt(.CooldownUntilDate)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MyBoost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode myBoost#c448415c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode myBoost#c448415c: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode myBoost#c448415c: field slot: %w", )
		}
		.Slot = 
	}
	if .Flags.Has(0) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode myBoost#c448415c: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode myBoost#c448415c: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode myBoost#c448415c: field expires: %w", )
		}
		.Expires = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode myBoost#c448415c: field cooldown_until_date: %w", )
		}
		.CooldownUntilDate = 
	}
	return nil
}

// GetSlot returns value of Slot field.
func ( *MyBoost) () ( int) {
	if  == nil {
		return
	}
	return .Slot
}

// SetPeer sets value of Peer conditional field.
func ( *MyBoost) ( PeerClass) {
	.Flags.Set(0)
	.Peer = 
}

// GetPeer returns value of Peer conditional field and
// boolean which is true if field was set.
func ( *MyBoost) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Peer, true
}

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

// GetExpires returns value of Expires field.
func ( *MyBoost) () ( int) {
	if  == nil {
		return
	}
	return .Expires
}

// SetCooldownUntilDate sets value of CooldownUntilDate conditional field.
func ( *MyBoost) ( int) {
	.Flags.Set(1)
	.CooldownUntilDate = 
}

// GetCooldownUntilDate returns value of CooldownUntilDate conditional field and
// boolean which is true if field was set.
func ( *MyBoost) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .CooldownUntilDate, true
}