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 anIntin0..=255. - nova_
rt_ ⚠bytes_ concat a’s bytes followed byb’s, in a freshly allocated buffer.- nova_
rt_ ⚠bytes_ eq - Byte-for-byte equality of
aandb. - nova_
rt_ ⚠bytes_ from_ ints - A
Bytesholding each element ofintsas one byte. - nova_
rt_ ⚠bytes_ from_ string - A
Bytesholdings’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 —Byteshas no encoding. - nova_
rt_ ⚠bytes_ slice - The bytes in
start..end, clamped to the buffer and tostart <= end. - nova_
rt_ ⚠bytes_ to_ ints - Decompose
binto a Nova[Int], one element per byte in0..=255. - nova_
rt_ ⚠bytes_ to_ string_ unchecked b’s bytes as aString, without checking UTF-8 validity.