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")

torb build ships the files of the Resource literals beside the binary, and bytes() and text() read them from there, failing with a ResourceError. This is slices 1 to 3 of the design: the types, the literal and the stable name, embedding, and shipping.

Modules

Everything