Skip to main content

Module bytes

Module bytes 

Source
Expand description

Byte-buffer intrinsics for std/bytes. pub, not private, for the same reason as fs: its own doc comment explains the boundary it implements (one representation, shared with NovaStr, distinguished only by hir::Ty). Branch byte-type’s own Task 3 (docs/superpowers/plans/2026-08-12-byte-type.md) added the rest of the byte surface beside this module’s first four intrinsics, the same way this crate’s other modules build on task. Byte-buffer intrinsics for std/bytes.

§Representation, and why there is no NovaBytes struct

A Bytes value is a crate::NovaStr — one GC leaf object, a {len, ptr} header followed inline by the bytes ptr points at. That is not an approximation: String and Bytes have the same layout and differ only in that String carries a UTF-8 guarantee, which lives in the type system rather than the representation.

A second struct with the same fields would be a second copy of a layout, which is the drift class this project has already shipped a miscompile from. So there is one struct and one set of allocation helpers, and the distinction is enforced by hir::Ty, not by Rust.

§Panic-freedom

Some of these are reachable from inside an async fn’s generated $poll, which has no landing pads, so nothing here may panic. Where a caller error must be rejected, it aborts — abort_with does not unwind.

Functions§

nova_rt_bytes_at⚠
The byte at i, as an Int in 0..=255.
nova_rt_bytes_concat⚠
a’s bytes followed by b’s, in a freshly allocated buffer.
nova_rt_bytes_eq⚠
Byte-for-byte equality of a and b.
nova_rt_bytes_from_ints⚠
A Bytes holding each element of ints as one byte.
nova_rt_bytes_from_string⚠
A Bytes holding s’s UTF-8 bytes.
nova_rt_bytes_is_utf8⚠
Whether b’s bytes are valid UTF-8.
nova_rt_bytes_len⚠
The byte length of b. Not a character count — Bytes has no encoding.
nova_rt_bytes_slice⚠
The bytes in start..end, clamped to the buffer and to start <= end.
nova_rt_bytes_to_ints⚠
Decompose b into a Nova [Int], one element per byte in 0..=255.
nova_rt_bytes_to_string_unchecked⚠
b’s bytes as a String, without checking UTF-8 validity.