pub fn write_to(dir: impl AsRef<Path>) -> Result<()>Expand description
Write the embedded package into dir, creating it if needed.
Overwrites whatever is there: the directory is a cache of this package, and a partial refresh — some files current, some stale — resolves into a WIT package that is internally inconsistent, which fails in ways far harder to read than a clean overwrite.
Files present in dir that are not part of the package are left alone.
A plugin may legitimately keep its own world file beside the package (org
does not, but the scaffolds’ world.wit shape would), and deleting a file
this crate did not write would be taking ownership of a directory it only
contributes to.
A file already holding the right bytes is not rewritten, and that is load-bearing rather than an optimisation. WT.2b calls this from the plugin build service on every boot, immediately before the source’s staleness is judged — and staleness is judged on mtime. An unconditional write would move every file’s mtime forward on every boot, so every source would look edited, so every plugin would rebuild from cold on every start. The requirement the build service exists to protect is precisely the opposite one.