OwnedBytesHandle

expect class OwnedBytesHandle

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.

actual class OwnedBytesHandle

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.

actual class OwnedBytesHandle

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.

actual class OwnedBytesHandle

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.

actual class OwnedBytesHandle

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

Link copied to clipboard
expect fun OwnedBytesHandle.asReadBuffer(): ReadBuffer

Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.

actual fun OwnedBytesHandle.asReadBuffer(): ReadBuffer

Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.

actual fun OwnedBytesHandle.asReadBuffer(): ReadBuffer

Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.

actual fun OwnedBytesHandle.asReadBuffer(): ReadBuffer

Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.

actual fun OwnedBytesHandle.asReadBuffer(): ReadBuffer

Returns a ReadBuffer view over the bytes storage, position reset to 0. The returned view aliases the handle's internal buffer — do not free.

Link copied to clipboard

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.

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

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.

Link copied to clipboard

Content hash.

Content hash.

Content hash.

Content hash.

Content hash.

hashCode
Link copied to clipboard
open override fun hashCode(): Int
open override fun hashCode(): Int
open override fun hashCode(): Int
open override fun hashCode(): Int