Canary script file format #30

Open
opened 2022-11-04 19:27:59 +00:00 by mars · 0 comments
Owner

I believe that there is a need for Canary scripts to have an extensible, easy-to-code metadata format that contains essential data such as the list of protocols that the script supports, its authors, its license, its website, pre-execution configuration, and other info to help the usability of the scripts. Before, I was thinking that Canary's metadata could be passed from the script to the host using strings copied from script memory, however, I now believe that the best long-term way to do this would be in a dedicated JSON metadata section that precedes the WebAssembly binary in a special file format. This way, script metadata can be rapidly read from without the need to instantiate its module to query the metadata.

File format:

  • four-byte magic number: "CNRY"
  • length of the metadata (little-endian u32)
  • the metadata JSON string
  • remainder of the file contains the WebAssembly module

Steps involved:

  • add serde and serde_json dependencies to the canary crate
  • add a new public file module
  • define and document a de/serializable JSON metadata document in Rust structs
  • create a new CanaryFile struct with the serialized JSON and WebAssembly binary as members
  • add a helper to read CanaryFile from impl Read

Future goals once this is done:

  • integrate the compilation of Canary script files into the build system
  • add a fontconfig-style store of scripts to Magpie in a suitable location on the filesystem
  • switch the location of new Magpie script modules to protocol names from .wasm paths

Also, what file extension should Canary scripts use?

I believe that there is a need for Canary scripts to have an extensible, easy-to-code metadata format that contains essential data such as the list of protocols that the script supports, its authors, its license, its website, pre-execution configuration, and other info to help the usability of the scripts. Before, I was thinking that Canary's metadata could be passed from the script to the host using strings copied from script memory, however, I now believe that the best long-term way to do this would be in a dedicated JSON metadata section that precedes the WebAssembly binary in a special file format. This way, script metadata can be rapidly read from without the need to instantiate its module to query the metadata. File format: - four-byte magic number: "CNRY" - length of the metadata (little-endian u32) - the metadata JSON string - remainder of the file contains the WebAssembly module Steps involved: - add serde and serde_json dependencies to the canary crate - add a new public `file` module - define and document a de/serializable JSON metadata document in Rust structs - create a new `CanaryFile` struct with the serialized JSON and WebAssembly binary as members - add a helper to read `CanaryFile` from `impl Read` Future goals once this is done: - integrate the compilation of Canary script files into the build system - add a fontconfig-style store of scripts to Magpie in a suitable location on the filesystem - switch the location of new Magpie script modules to protocol names from .wasm paths Also, what file extension should Canary scripts use?
mars added the
feature
label 2022-11-04 19:27:59 +00:00
mars self-assigned this 2022-12-04 21:41:04 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: canary/canary-rs#30
No description provided.