Embed
Embed exposes binary literals and helps source-time producers create them. Importing the library does not run the embedded data. An embedded literal is represented by BitString*, with an exact bit count and a borrowed byte pointer.
First example
import embed
let check_blob = fn () -> i64 {
let blob = bits"10101010_11110000"
if Embed:bits(blob) != 16 || Embed:bytes(blob) != 2 { return 1 }
let data = Embed:data(blob)
return data[0] != 170 || data[1] != 240
}
assert check_blob() == 0Learning path
- Bit layout — Understand exact lengths and partial bytes.
- Native data — Pass borrowed bytes across native interfaces.
- Syntax producers — Generate literals while elaborating syntax.