Documentation
¶
Overview ¶
Package serialization provides persisted payload codecs and compatibility fingerprints.
Index ¶
Constants ¶
const JSONCodecVersion = "json/v1"
JSONCodecVersion identifies the persisted format produced by JSONCodec.
const (
// PayloadWarningThreshold is the encoded size above which Cord reports a large payload.
PayloadWarningThreshold = 256 * 1024
)
Variables ¶
This section is empty.
Functions ¶
func SignatureFingerprint ¶
SignatureFingerprint hashes ordered input and output type fingerprints.
func TypeFingerprint ¶
TypeFingerprint hashes a Go type identity together with its codec version. Generic instantiations are rejected because reflection does not expose their type arguments with enough package information to identify them canonically.
Types ¶
type JSONCodec ¶
type JSONCodec[T any] struct{}
JSONCodec encodes and decodes one non-interface Go type using encoding/json. Its zero value is ready to use.
func NewJSONCodec ¶
NewJSONCodec creates a typed JSON codec. It rejects T when its reachable structure contains an interface because encoding/json cannot preserve arbitrary dynamic Go types, integer widths, or typed nil values when decoding an interface.
func (JSONCodec[T]) TypeFingerprint ¶
TypeFingerprint returns the codec-specific fingerprint for T. It computes the value lazily, so a zero-value JSONCodec never yields an empty fingerprint.
type PayloadDiagnostic ¶
PayloadDiagnostic describes an unusually large encoded payload without exposing its contents.
func DiagnosePayload ¶
func DiagnosePayload(payload []byte) (PayloadDiagnostic, bool)
DiagnosePayload reports whether payload exceeds the recommended warning threshold.