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

// PhotosPhotos represents TL type `photos.photos#8dca6aa5`.
// Full list of photos with auxiliary data.
//
// See https://core.telegram.org/constructor/photos.photos for reference.
type PhotosPhotos struct {
	// List of photos
	Photos []PhotoClass
	// List of mentioned users
	Users []UserClass
}

// PhotosPhotosTypeID is TL type id of PhotosPhotos.
const PhotosPhotosTypeID = 0x8dca6aa5

// construct implements constructor of PhotosPhotosClass.
func ( PhotosPhotos) () PhotosPhotosClass { return & }

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

	_ PhotosPhotosClass = &PhotosPhotos{}
)

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *PhotosPhotos) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode photos.photos#8dca6aa5 as nil")
	}
	.PutID(PhotosPhotosTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *PhotosPhotos) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.photos#8dca6aa5 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode photos.photos#8dca6aa5: field photos: %w", )
		}

		if  > 0 {
			.Photos = make([]PhotoClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodePhoto()
			if  != nil {
				return fmt.Errorf("unable to decode photos.photos#8dca6aa5: field photos: %w", )
			}
			.Photos = append(.Photos, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode photos.photos#8dca6aa5: field users: %w", )
		}

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

// GetPhotos returns value of Photos field.
func ( *PhotosPhotos) () ( []PhotoClass) {
	if  == nil {
		return
	}
	return .Photos
}

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

// MapPhotos returns field Photos wrapped in PhotoClassArray helper.
func ( *PhotosPhotos) () ( PhotoClassArray) {
	return PhotoClassArray(.Photos)
}

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

// PhotosPhotosSlice represents TL type `photos.photosSlice#15051f54`.
// Incomplete list of photos with auxiliary data.
//
// See https://core.telegram.org/constructor/photos.photosSlice for reference.
type PhotosPhotosSlice struct {
	// Total number of photos
	Count int
	// List of photos
	Photos []PhotoClass
	// List of mentioned users
	Users []UserClass
}

// PhotosPhotosSliceTypeID is TL type id of PhotosPhotosSlice.
const PhotosPhotosSliceTypeID = 0x15051f54

// construct implements constructor of PhotosPhotosClass.
func ( PhotosPhotosSlice) () PhotosPhotosClass { return & }

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

	_ PhotosPhotosClass = &PhotosPhotosSlice{}
)

func ( *PhotosPhotosSlice) () bool {
	if  == nil {
		return true
	}
	if !(.Count == 0) {
		return false
	}
	if !(.Photos == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PhotosPhotosSlice from given interface.
func ( *PhotosPhotosSlice) ( interface {
	() ( int)
	() ( []PhotoClass)
	() ( []UserClass)
}) {
	.Count = .()
	.Photos = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PhotosPhotosSlice) () tdp.Type {
	 := tdp.Type{
		Name: "photos.photosSlice",
		ID:   PhotosPhotosSliceTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Photos",
			SchemaName: "photos",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhotosPhotosSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode photos.photosSlice#15051f54 as nil")
	}
	.PutID(PhotosPhotosSliceTypeID)
	return .EncodeBare()
}

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

// Decode implements bin.Decoder.
func ( *PhotosPhotosSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.photosSlice#15051f54 to nil")
	}
	if  := .ConsumeID(PhotosPhotosSliceTypeID);  != nil {
		return fmt.Errorf("unable to decode photos.photosSlice#15051f54: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhotosPhotosSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.photosSlice#15051f54 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode photos.photosSlice#15051f54: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode photos.photosSlice#15051f54: field photos: %w", )
		}

		if  > 0 {
			.Photos = make([]PhotoClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodePhoto()
			if  != nil {
				return fmt.Errorf("unable to decode photos.photosSlice#15051f54: field photos: %w", )
			}
			.Photos = append(.Photos, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode photos.photosSlice#15051f54: field users: %w", )
		}

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

// GetCount returns value of Count field.
func ( *PhotosPhotosSlice) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

// GetPhotos returns value of Photos field.
func ( *PhotosPhotosSlice) () ( []PhotoClass) {
	if  == nil {
		return
	}
	return .Photos
}

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

// MapPhotos returns field Photos wrapped in PhotoClassArray helper.
func ( *PhotosPhotosSlice) () ( PhotoClassArray) {
	return PhotoClassArray(.Photos)
}

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

// PhotosPhotosClassName is schema name of PhotosPhotosClass.
const PhotosPhotosClassName = "photos.Photos"

// PhotosPhotosClass represents photos.Photos generic type.
//
// See https://core.telegram.org/type/photos.Photos for reference.
//
// Example:
//
//	g, err := tg.DecodePhotosPhotos(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PhotosPhotos: // photos.photos#8dca6aa5
//	case *tg.PhotosPhotosSlice: // photos.photosSlice#15051f54
//	default: panic(v)
//	}
type PhotosPhotosClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PhotosPhotosClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// List of photos
	GetPhotos() (value []PhotoClass)
	// List of photos
	MapPhotos() (value PhotoClassArray)
	// List of mentioned users
	GetUsers() (value []UserClass)
	// List of mentioned users
	MapUsers() (value UserClassArray)
}

// DecodePhotosPhotos implements binary de-serialization for PhotosPhotosClass.
func ( *bin.Buffer) (PhotosPhotosClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PhotosPhotosTypeID:
		// Decoding photos.photos#8dca6aa5.
		 := PhotosPhotos{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhotosPhotosClass: %w", )
		}
		return &, nil
	case PhotosPhotosSliceTypeID:
		// Decoding photos.photosSlice#15051f54.
		 := PhotosPhotosSlice{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhotosPhotosClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PhotosPhotosClass: %w", bin.NewUnexpectedID())
	}
}

// PhotosPhotos boxes the PhotosPhotosClass providing a helper.
type PhotosPhotosBox struct {
	Photos PhotosPhotosClass
}

// Decode implements bin.Decoder for PhotosPhotosBox.
func ( *PhotosPhotosBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode PhotosPhotosBox to nil")
	}
	,  := DecodePhotosPhotos()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.Photos = 
	return nil
}

// Encode implements bin.Encode for PhotosPhotosBox.
func ( *PhotosPhotosBox) ( *bin.Buffer) error {
	if  == nil || .Photos == nil {
		return fmt.Errorf("unable to encode PhotosPhotosClass as nil")
	}
	return .Photos.Encode()
}