<commit_before>/* For license and copyright information please see LEGAL file in repository */

package srpc

import "../syllab"

/*
	********************PAY ATTENTION:*******************
	We don't suggest use these 2 func instead use chaparkhane to autogenerate needed code before compile time
	and reduce runtime proccess to improve performance of the app and gain max performance from this protocol!
*/

// MarshalPacket use to encode automatically the value of s to the payload buffer.
func MarshalPacket(p []byte, id uint32, s interface{}) (err error) {
	// Set ServiceID to payload
	SetID(p, id)

	// encode s to p by syllab encoder
	err = syllab.MarshalSyllab(p[4:], s)

	return err
}

// UnMarshalPacket use to decode automatically payload and stores the result
// in the value pointed to by s.
func UnMarshalPacket(p []byte, expectedMinLen int, s interface{}) (id uint32, err error) {
	err = CheckPacket(p, expectedMinLen)
	if err != nil {
		return 0, err
	}

	// Get ErrorID from payload
	id = GetID(p)

	// decode payload to s by syllab encoder
	err = syllab.UnMarshalSyllab(p[4:], s)

	return id, err
}<commit_msg>Fix logic and typo in sRPC<commit_after>/* For license and copyright information please see LEGAL file in repository */

package srpc

import "../syllab"

/*
	********************PAY ATTENTION:*******************
	We don't suggest use these 2 func instead use chaparkhane to autogenerate needed code before compile time
	and reduce runtime proccess to improve performance of the app and gain max performance from this protocol!
*/

// MarshalPacket use to encode automatically the value of s to the payload buffer.
func MarshalPacket(id uint32, s interface{}) (p []byte, err error) {
	// encode s to p by syllab encoder
	p, err = syllab.Marshal(s, 4)

	// Set ServiceID to first of payload
	SetID(p, id)

	return
}

// UnMarshalPacket use to decode automatically payload and stores the result
// in the value pointed to by s.
func UnMarshalPacket(p []byte, expectedMinLen int, s interface{}) (id uint32, err error) {
	err = CheckPacket(p, expectedMinLen)
	if err != nil {
		return 0, err
	}

	// Get ErrorID from payload
	id = GetID(p)

	// decode payload to s by syllab encoder
	err = syllab.UnMarshal(p[4:], s)

	return
}
{'fraction_non_alphanumeric': 0.1151622943530458, 'fraction_numerical': 0.007114273010226767, 'mean_word_length': 4.022321428571429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6507872', 'n_tokens_mistral': 694, 'n_tokens_neox': 651, 'n_words': 301}