std/resource
Files a program needs, named by a string literal where the signature says what kind of file it is
(docs/design/RESOURCES.md): a Resource ships beside the program and is read while it runs, an EmbeddedBytes and
an EmbeddedText are in the binary. A literal where one of them is expected is resolved by the compiler against the
file that writes it, and a file that is not there is an error at that line; a String value never becomes one.
fn load(sheet: Resource): String {
sheet.name()
}
print load("./hero.png")
This is slice 1 of the design: the types, the literal and the stable name. Reading the bytes - embedding them and shipping them - is slices 2 and 3.
Modules
std/resource/resource[Resource], [EmbeddedBytes] and [EmbeddedText]: the three types a string literal names a file of the package with (docs/design/RESOURCES.md section 4).
Everything
- type
EmbeddedBytesA file whose bytes are in the binary. - type
EmbeddedTextA file whose text is in the binary, so reading it cannot fail: the compiler reads the file, and checks its UTF-8, where the literal names it (slice 2 of docs/design/RESOURCES.md). - type
ResourceA file that ships with the program and is read while it runs, found relative to the program and never to the working directory.