network/metadata/metadata.go

22 lines
708 B
Go
Raw Normal View History

2023-04-05 16:15:59 +08:00
// Package metadata defines `Metadata` and the `Builder`.
package metadata
import "git.hpds.cc/Component/network/frame"
// Metadata is used for storing extra info of the application.
type Metadata interface {
// Encode is the serialize method,
// That represents the Metadata can be transmitted.
Encode() []byte
}
// Builder is the builder of Metadata.
// the metadata usually be built from `HandshakeFrame`,
// and It can be decode as byte array for io transmission.
type Builder interface {
// Build returns a Metadata instance according to the handshake frame passed in.
Build(f *frame.HandshakeFrame) (Metadata, error)
// Decode is the deserialize method
Decode(buf []byte) (Metadata, error)
}