package proto

import (
	

	
)

// UnencryptedMessage is plaintext message.
type UnencryptedMessage struct {
	MessageID   int64
	MessageData []byte
}

// Decode implements bin.Decoder.
func ( *UnencryptedMessage) ( *bin.Buffer) error {
	{
		// Reading auth_key_id that should be always equal to zero.
		,  := .Long()
		if  != nil {
			return 
		}
		if  != 0 {
			return errors.Errorf("unexpected auth_key_id %d of plaintext message", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return 
		}
		.MessageID = 
	}

	// Reading data.
	,  := .Int32()
	if  != nil {
		return 
	}
	.MessageData = append(.MessageData[:0], make([]byte, )...)
	if  := .ConsumeN(.MessageData, int());  != nil {
		return errors.Wrap(, "consume payload")
	}

	return nil
}

// Encode implements bin.Encoder.
func ( UnencryptedMessage) ( *bin.Buffer) error {
	.PutLong(0)
	.PutLong(.MessageID)
	.PutInt32(int32(len(.MessageData)))
	.Put(.MessageData)
	return nil
}