type Marshaler interface {
func MarshalType(
val reflect.Value,
b []byte,
lastWrittenIdx uint64,
) (nextIdx uint64, error)
}
type Unmarshaler interface {
func UnmarshalType(
target reflect.Value,
b []byte,
lastReadIdx uint64,
) (nextIdx uint64, error)
}
Techopedia defines serialization as
The process of converting the state information of an object instance into a binary or textual form to persist into storage medium or transported over a network.
In simple words, it is the task of translating data using a common set of rules a standard system can understand, as well as the task of decoding translated data back into its original form using the same set of rules. All computers function around the notion of 1s and 0s, otherwise known as bits, which give us a convenient, common format we can serialize into.
The process of serializing data is called Marshaling, and the process of recovering original data from some serialized bytes is known as Unmarshaling. We will be using the two terms extensively throughout this post.