mirror of
https://github.com/fluencelabs/wasmer
synced 2025-05-12 02:27:11 +00:00
feat(wasi) Add the “volatile” WasiVersion::Latest
version.
In addition to `Snapshot0` and `Snapshot1`, I believe it is an interesting API to provide the `Latest` version, so that the user can write: ```rust generate_import_object_for_version(WasiVersion::Latest, …); ``` This is a way to ensure that modules will run only if they come with the latest WASI version (in case of security issues for instance), by just updating the runtime. Note that it can be dangerous if not used carefully, but we assume the user knows what it does by sticking on a specific “floating” version. Also note that the `Latest` version is never returned by any API. It is provided only by the user.
This commit is contained in:
parent
19dfdec236
commit
a79beede72
@ -142,7 +142,9 @@ pub fn generate_import_object_for_version(
|
||||
WasiVersion::Snapshot0 => {
|
||||
generate_import_object_snapshot0(args, envs, preopened_files, mapped_dirs)
|
||||
}
|
||||
WasiVersion::Snapshot1 => generate_import_object(args, envs, preopened_files, mapped_dirs),
|
||||
WasiVersion::Snapshot1 | WasiVersion::Latest => {
|
||||
generate_import_object(args, envs, preopened_files, mapped_dirs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,16 @@ pub fn is_wasi_module(module: &Module) -> bool {
|
||||
get_wasi_version(module).is_some()
|
||||
}
|
||||
|
||||
/// The version of WASI. This is determined by the namespace string
|
||||
/// The version of WASI. This is determined by the imports namespace
|
||||
/// string.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum WasiVersion {
|
||||
/// "wasi_unstable"
|
||||
/// `wasi_unstable`.
|
||||
Snapshot0,
|
||||
/// "wasi_snapshot_preview1"
|
||||
/// `wasi_snapshot_preview1`.
|
||||
Snapshot1,
|
||||
/// Latest version (for the moment, an alias to `Snapshot1`).
|
||||
Latest,
|
||||
}
|
||||
|
||||
/// Detect the version of WASI being used from the namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user