// Code generated by gotdgen, DO NOT EDIT.

package tdapi

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// GetStorageStatisticsFastRequest represents TL type `getStorageStatisticsFast#3a86702`.
type GetStorageStatisticsFastRequest struct {
}

// GetStorageStatisticsFastRequestTypeID is TL type id of GetStorageStatisticsFastRequest.
const GetStorageStatisticsFastRequestTypeID = 0x3a86702

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

func (g *GetStorageStatisticsFastRequest) Zero() bool {
	if g == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (g *GetStorageStatisticsFastRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "getStorageStatisticsFast",
		ID:   GetStorageStatisticsFastRequestTypeID,
	}
	if g == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (g *GetStorageStatisticsFastRequest) Encode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getStorageStatisticsFast#3a86702 as nil")
	}
	b.PutID(GetStorageStatisticsFastRequestTypeID)
	return g.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (g *GetStorageStatisticsFastRequest) EncodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't encode getStorageStatisticsFast#3a86702 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (g *GetStorageStatisticsFastRequest) Decode(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getStorageStatisticsFast#3a86702 to nil")
	}
	if err := b.ConsumeID(GetStorageStatisticsFastRequestTypeID); err != nil {
		return fmt.Errorf("unable to decode getStorageStatisticsFast#3a86702: %w", err)
	}
	return g.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (g *GetStorageStatisticsFastRequest) DecodeBare(b *bin.Buffer) error {
	if g == nil {
		return fmt.Errorf("can't decode getStorageStatisticsFast#3a86702 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetStorageStatisticsFastRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
	if g == nil {
		return fmt.Errorf("can't encode getStorageStatisticsFast#3a86702 as nil")
	}
	b.ObjStart()
	b.PutID("getStorageStatisticsFast")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetStorageStatisticsFastRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
	if g == nil {
		return fmt.Errorf("can't decode getStorageStatisticsFast#3a86702 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("getStorageStatisticsFast"); err != nil {
				return fmt.Errorf("unable to decode getStorageStatisticsFast#3a86702: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetStorageStatisticsFast invokes method getStorageStatisticsFast#3a86702 returning error if any.
func (c *Client) GetStorageStatisticsFast(ctx context.Context) (*StorageStatisticsFast, error) {
	var result StorageStatisticsFast

	request := &GetStorageStatisticsFastRequest{}
	if err := c.rpc.Invoke(ctx, request, &result); err != nil {
		return nil, err
	}
	return &result, nil
}
