Owned Bytes Handle
Opaque, platform-typed handle for bytes that need to outlive the wire frame they were decoded from — IPC forwarding, persistence, debug capture, default-decode for payloads whose codec isn't pinned at decode time.
Shape: the canonical Pattern #2 from the buffer-codec lockdown plan (consumer-owned PlatformBuffer allocated via factory.allocate(...) + write(source)). The handle's actual stores a PlatformBuffer internally on every platform; the expect class boundary is what shields KSP's transitive Payload-shape walk from descending into the internal buffer field. Walker sees the property typed as OwnedBytesHandle, finds the type is not forbidden, not Payload, not a value class — and stops.
OwnedBytesHandle is intentionally not a Payload itself — protocol- specific concerns (mqtt's PublishPayload, websocket's binary message type, etc.) supply their own thin wrapper that does the Payload marker duty. The companion codec OwnedBytesHandleCodec implements the canonical decode/encode flow that those wrappers' codecs delegate to.
Equality: every platform actual overrides equals / hashCode to delegate to handleEquals / handleHashCode (byte-content comparison). Two handles with the same bytes are ==, so data class containers that carry an OwnedBytesHandle field get structural equality "for free" without each declaring custom equals themselves.
Opaque, platform-typed handle for bytes that need to outlive the wire frame they were decoded from — IPC forwarding, persistence, debug capture, default-decode for payloads whose codec isn't pinned at decode time.
Shape: the canonical Pattern #2 from the buffer-codec lockdown plan (consumer-owned PlatformBuffer allocated via factory.allocate(...) + write(source)). The handle's actual stores a PlatformBuffer internally on every platform; the expect class boundary is what shields KSP's transitive Payload-shape walk from descending into the internal buffer field. Walker sees the property typed as OwnedBytesHandle, finds the type is not forbidden, not Payload, not a value class — and stops.
OwnedBytesHandle is intentionally not a Payload itself — protocol- specific concerns (mqtt's PublishPayload, websocket's binary message type, etc.) supply their own thin wrapper that does the Payload marker duty. The companion codec OwnedBytesHandleCodec implements the canonical decode/encode flow that those wrappers' codecs delegate to.
Equality: every platform actual overrides equals / hashCode to delegate to handleEquals / handleHashCode (byte-content comparison). Two handles with the same bytes are ==, so data class containers that carry an OwnedBytesHandle field get structural equality "for free" without each declaring custom equals themselves.
JVM + Android actual for OwnedBytesHandle. See common kdoc for design rationale; both jvm and androidTarget source-sets dependsOn jvmCommonMain so this single file serves both.
Opaque, platform-typed handle for bytes that need to outlive the wire frame they were decoded from — IPC forwarding, persistence, debug capture, default-decode for payloads whose codec isn't pinned at decode time.
Shape: the canonical Pattern #2 from the buffer-codec lockdown plan (consumer-owned PlatformBuffer allocated via factory.allocate(...) + write(source)). The handle's actual stores a PlatformBuffer internally on every platform; the expect class boundary is what shields KSP's transitive Payload-shape walk from descending into the internal buffer field. Walker sees the property typed as OwnedBytesHandle, finds the type is not forbidden, not Payload, not a value class — and stops.
OwnedBytesHandle is intentionally not a Payload itself — protocol- specific concerns (mqtt's PublishPayload, websocket's binary message type, etc.) supply their own thin wrapper that does the Payload marker duty. The companion codec OwnedBytesHandleCodec implements the canonical decode/encode flow that those wrappers' codecs delegate to.
Equality: every platform actual overrides equals / hashCode to delegate to handleEquals / handleHashCode (byte-content comparison). Two handles with the same bytes are ==, so data class containers that carry an OwnedBytesHandle field get structural equality "for free" without each declaring custom equals themselves.
Opaque, platform-typed handle for bytes that need to outlive the wire frame they were decoded from — IPC forwarding, persistence, debug capture, default-decode for payloads whose codec isn't pinned at decode time.
Shape: the canonical Pattern #2 from the buffer-codec lockdown plan (consumer-owned PlatformBuffer allocated via factory.allocate(...) + write(source)). The handle's actual stores a PlatformBuffer internally on every platform; the expect class boundary is what shields KSP's transitive Payload-shape walk from descending into the internal buffer field. Walker sees the property typed as OwnedBytesHandle, finds the type is not forbidden, not Payload, not a value class — and stops.
OwnedBytesHandle is intentionally not a Payload itself — protocol- specific concerns (mqtt's PublishPayload, websocket's binary message type, etc.) supply their own thin wrapper that does the Payload marker duty. The companion codec OwnedBytesHandleCodec implements the canonical decode/encode flow that those wrappers' codecs delegate to.
Equality: every platform actual overrides equals / hashCode to delegate to handleEquals / handleHashCode (byte-content comparison). Two handles with the same bytes are ==, so data class containers that carry an OwnedBytesHandle field get structural equality "for free" without each declaring custom equals themselves.
Functions
Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.
Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.
Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.
Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.
Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.
Number of bytes carried by this handle.
Number of bytes carried by this handle.
Number of bytes carried by this handle.
Number of bytes carried by this handle.
Number of bytes carried by this handle.
Content-equality across two handles.
Content-equality across two handles.
Content-equality across two handles.
Content-equality across two handles.
Content-equality across two handles.
Content hash.
Content hash.
Content hash.
Content hash.
Content hash.