Skip to main content

Crate mago_bytes

Crate mago_bytes 

Source
Expand description

Shared byte-slice utilities for the Mago toolchain.

PHP source code is binary-safe, so the toolchain handles identifiers, comments, and string literals as &[u8] end-to-end. Diagnostic messages and human-facing logs are UTF-8 strings, so a tiny adapter layer is needed at the display boundary. This crate is that adapter, plus a few SIMD-accelerated byte-trimming primitives.

Structs§

BytesDisplay
Renders a byte slice as text for diagnostic messages.

Functions§

trim_byte
Strips all leading and trailing occurrences of byte from s.
trim_end_byte
Strips all trailing occurrences of byte from s.
trim_start_byte
Strips all leading occurrences of byte from s.
write_escaped
Writes bytes to f, rendering valid UTF-8 verbatim and every byte that is not part of a valid UTF-8 sequence as a \xHH hex escape.