// Code generated by gotdgen, DO NOT EDIT.

package mt

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

// MsgContainer represents TL type `msg_container#73f1f8dc`.
type MsgContainer struct {
	// Messages field of MsgContainer.
	Messages []Message
}

// MsgContainerTypeID is TL type id of MsgContainer.
const MsgContainerTypeID = 0x73f1f8dc

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

func ( *MsgContainer) () bool {
	if  == nil {
		return true
	}
	if !(.Messages == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *MsgContainer) () tdp.Type {
	 := tdp.Type{
		Name: "msg_container",
		ID:   MsgContainerTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Messages",
			SchemaName: "messages",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MsgContainer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode msg_container#73f1f8dc as nil")
	}
	.PutID(MsgContainerTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MsgContainer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode msg_container#73f1f8dc as nil")
	}
	.PutInt(len(.Messages))
	for ,  := range .Messages {
		if  := .EncodeBare();  != nil {
			return fmt.Errorf("unable to encode bare msg_container#73f1f8dc: field messages element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MsgContainer) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode msg_container#73f1f8dc to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode msg_container#73f1f8dc: field messages: %w", )
		}

		if  > 0 {
			.Messages = make([]Message, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  Message
			if  := .DecodeBare();  != nil {
				return fmt.Errorf("unable to decode bare msg_container#73f1f8dc: field messages: %w", )
			}
			.Messages = append(.Messages, )
		}
	}
	return nil
}

// GetMessages returns value of Messages field.
func ( *MsgContainer) () ( []Message) {
	if  == nil {
		return
	}
	return .Messages
}