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

// AccountWebAuthorizations represents TL type `account.webAuthorizations#ed56c9fc`.
// Web authorizations
//
// See https://core.telegram.org/constructor/account.webAuthorizations for reference.
type AccountWebAuthorizations struct {
	// Web authorization list
	Authorizations []WebAuthorization
	// Users
	Users []UserClass
}

// AccountWebAuthorizationsTypeID is TL type id of AccountWebAuthorizations.
const AccountWebAuthorizationsTypeID = 0xed56c9fc

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

func ( *AccountWebAuthorizations) () bool {
	if  == nil {
		return true
	}
	if !(.Authorizations == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountWebAuthorizations from given interface.
func ( *AccountWebAuthorizations) ( interface {
	() ( []WebAuthorization)
	() ( []UserClass)
}) {
	.Authorizations = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountWebAuthorizations) () string {
	return "account.webAuthorizations"
}

// TypeInfo returns info about TL type.
func ( *AccountWebAuthorizations) () tdp.Type {
	 := tdp.Type{
		Name: "account.webAuthorizations",
		ID:   AccountWebAuthorizationsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Authorizations",
			SchemaName: "authorizations",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountWebAuthorizations) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.webAuthorizations#ed56c9fc as nil")
	}
	.PutID(AccountWebAuthorizationsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountWebAuthorizations) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.webAuthorizations#ed56c9fc as nil")
	}
	.PutVectorHeader(len(.Authorizations))
	for ,  := range .Authorizations {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.webAuthorizations#ed56c9fc: field authorizations element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode account.webAuthorizations#ed56c9fc: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.webAuthorizations#ed56c9fc: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountWebAuthorizations) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.webAuthorizations#ed56c9fc to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.webAuthorizations#ed56c9fc: field authorizations: %w", )
		}

		if  > 0 {
			.Authorizations = make([]WebAuthorization, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  WebAuthorization
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.webAuthorizations#ed56c9fc: field authorizations: %w", )
			}
			.Authorizations = append(.Authorizations, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.webAuthorizations#ed56c9fc: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode account.webAuthorizations#ed56c9fc: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetAuthorizations returns value of Authorizations field.
func ( *AccountWebAuthorizations) () ( []WebAuthorization) {
	if  == nil {
		return
	}
	return .Authorizations
}

// GetUsers returns value of Users field.
func ( *AccountWebAuthorizations) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *AccountWebAuthorizations) () ( UserClassArray) {
	return UserClassArray(.Users)
}