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

// PhotosPhoto represents TL type `photos.photo#20212ca8`.
// Photo with auxiliary data.
//
// See https://core.telegram.org/constructor/photos.photo for reference.
type PhotosPhoto struct {
	// Photo
	Photo PhotoClass
	// Users
	Users []UserClass
}

// PhotosPhotoTypeID is TL type id of PhotosPhoto.
const PhotosPhotoTypeID = 0x20212ca8

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

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

	return true
}

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

// FillFrom fills PhotosPhoto from given interface.
func ( *PhotosPhoto) ( interface {
	() ( PhotoClass)
	() ( []UserClass)
}) {
	.Photo = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*PhotosPhoto) () string {
	return "photos.photo"
}

// TypeInfo returns info about TL type.
func ( *PhotosPhoto) () tdp.Type {
	 := tdp.Type{
		Name: "photos.photo",
		ID:   PhotosPhotoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Photo",
			SchemaName: "photo",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhotosPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode photos.photo#20212ca8 as nil")
	}
	.PutID(PhotosPhotoTypeID)
	return .EncodeBare()
}

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

// Decode implements bin.Decoder.
func ( *PhotosPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.photo#20212ca8 to nil")
	}
	if  := .ConsumeID(PhotosPhotoTypeID);  != nil {
		return fmt.Errorf("unable to decode photos.photo#20212ca8: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhotosPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.photo#20212ca8 to nil")
	}
	{
		,  := DecodePhoto()
		if  != nil {
			return fmt.Errorf("unable to decode photos.photo#20212ca8: field photo: %w", )
		}
		.Photo = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode photos.photo#20212ca8: field users: %w", )
		}

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

// GetPhoto returns value of Photo field.
func ( *PhotosPhoto) () ( PhotoClass) {
	if  == nil {
		return
	}
	return .Photo
}

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

// GetPhotoAsNotEmpty returns mapped value of Photo field.
func ( *PhotosPhoto) () (*Photo, bool) {
	return .Photo.AsNotEmpty()
}

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