Skip to content

Commit

Permalink
feat(wasi) Provide WasiState::(un)freeze if enable-serde is enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Aug 31, 2021
1 parent 4eaa864 commit a12ec28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/wasi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ wasmer = { path = "../api", version = "2.0.0", default-features = false }
wasmer-vfs = { path = "../vfs", version = "2.0.0", default-features = false }
typetag = { version = "0.1", optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
bincode = { version = "1.3", optional = true }

[target.'cfg(unix)'.dependencies]
libc = { version = "^0.2", default-features = false }
Expand Down Expand Up @@ -56,4 +57,4 @@ disable-all-logging = [
"tracing/release_max_level_off",
"tracing/max_level_off"
]
enable-serde = ["typetag", "serde"]
enable-serde = ["typetag", "serde", "bincode"]
10 changes: 5 additions & 5 deletions lib/wasi/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1571,15 +1571,15 @@ impl WasiState {
}

/// Turn the WasiState into bytes
#[cfg(feature = "enable-serde")]
pub fn freeze(&self) -> Option<Vec<u8>> {
todo!("temporarily disabled")
//bincode::serialize(self).ok()
bincode::serialize(self).ok()
}

/// Get a WasiState from bytes
pub fn unfreeze(_bytes: &[u8]) -> Option<Self> {
todo!("temporarily disabled")
//bincode::deserialize(bytes).ok()
#[cfg(feature = "enable-serde")]
pub fn unfreeze(bytes: &[u8]) -> Option<Self> {
bincode::deserialize(bytes).ok()
}
}

Expand Down

0 comments on commit a12ec28

Please sign in to comment.