StateTransferCodecInterface
Serializes {@see StateSnapshot} and {@see InteractionRequest} to and from wire strings the client round-trips (e.g. embedded in a `<milpa-state>` element in the SSR'd page, then echoed back verbatim on the next interaction). Because the client is untrusted, {@see \Milpa\Live\Http\LiveEndpoint} relies on a signed decorator of this interface (pairing an inner codec with a {@see \Milpa\Live\Contracts\Security\StateSignerInterface}) so a decoded snapshot is provably the one the server last issued — plain encode/decode here carries no authenticity guarantee by itself.
StateTransferCodecInterface::encodeState()
abstract public function encodeState(Milpa\Live\ValueObjects\StateSnapshot $snapshot): stringSerializes a state snapshot to a wire string.
Parameters
| Name | Type | Description |
|---|---|---|
| $snapshot | Milpa\Live\ValueObjects\StateSnapshot |
StateTransferCodecInterface::decodeState()
abstract public function decodeState(string $encoded): Milpa\Live\ValueObjects\StateSnapshotParses a wire string back into a {@see StateSnapshot}.
Parameters
| Name | Type | Description |
|---|---|---|
| $encoded | string |
Throws
\RuntimeException If `$encoded` is not well-formed, or (for signed implementations) fails
signature verification.
StateTransferCodecInterface::encodeInteraction()
abstract public function encodeInteraction(Milpa\Live\ValueObjects\InteractionRequest $request): stringSerializes an interaction request to a wire string.
Parameters
| Name | Type | Description |
|---|---|---|
| $request | Milpa\Live\ValueObjects\InteractionRequest |
StateTransferCodecInterface::decodeInteraction()
abstract public function decodeInteraction(string $encoded): Milpa\Live\ValueObjects\InteractionRequestParses a wire string back into an {@see InteractionRequest}.
Parameters
| Name | Type | Description |
|---|---|---|
| $encoded | string |
Throws
\RuntimeException If `$encoded` is not well-formed, or (for signed implementations) fails
signature verification.