diff --git a/examples/wasmtime/Cargo.toml b/examples/wasmtime/Cargo.toml index fe2368f41..373ccb2ae 100644 --- a/examples/wasmtime/Cargo.toml +++ b/examples/wasmtime/Cargo.toml @@ -19,7 +19,7 @@ log = { version = "0.4" } #, features = ["kv_unstable"]} simple_logger = { version = "5.0", default-features = false } # FIXME: remove `gc` feature once upgraded to wasmtime 25: wasmtime = { version = "24.0", default-features = false, features = ["std", "gc", "runtime", "cranelift", "threads", "parallel-compilation"] } #"pooling-allocator", "incremental-cache", "wat", "gc", "component-model"] } -zerocopy = { version = "0.7", default-features = false, features = ["alloc", "derive", "simd-nightly"] } +zerocopy = { version = "0.8", default-features = false, features = ["alloc", "derive", "simd-nightly"] } [target.'cfg(target_os = "hermit")'.dependencies] hermit = { path = "../../hermit", default-features = false, features = ["acpi", "pci", "fsgsbase", "fs", "tcp", "dhcpv4", "mmap"] } diff --git a/examples/wasmtime/src/preview1.rs b/examples/wasmtime/src/preview1.rs index b3a51c79c..b99222a6e 100644 --- a/examples/wasmtime/src/preview1.rs +++ b/examples/wasmtime/src/preview1.rs @@ -15,7 +15,7 @@ use bitflags::bitflags; use log::debug; use wasi::*; use wasmtime::{AsContext, AsContextMut, Caller, Extern}; -use zerocopy::AsBytes; +use zerocopy::{IntoBytes, KnownLayout, Immutable}; static FD: Mutex> = Mutex::new(Vec::new()); @@ -74,7 +74,7 @@ const SOCKET_STREAM: u8 = 1 << 5; /// The file refers to a symbolic link inode. const SYMBOLIC_LINK: u8 = 1 << 6; -#[derive(Debug, Copy, Clone, Default, AsBytes)] +#[derive(Debug, Copy, Clone, Default, IntoBytes, KnownLayout, Immutable)] #[repr(C)] pub(crate) struct FileStat { pub dev: u64, @@ -90,7 +90,7 @@ pub(crate) struct FileStat { pub ctim: u64, } -#[derive(Debug, Copy, Clone, Default, AsBytes)] +#[derive(Debug, Copy, Clone, Default, IntoBytes, KnownLayout, Immutable)] #[repr(C)] pub(crate) struct FdStat { pub filetype: u8, @@ -191,7 +191,7 @@ pub(crate) fn init(linker: &mut wasmtime::Linker) -> Result<()> { let _ = mem.read( caller.as_context_mut(), path_ptr.try_into().unwrap(), - path.as_bytes_mut(), + path.as_mut_bytes(), ); let path = "/".to_owned() + std::str::from_utf8(&path).unwrap(); @@ -250,7 +250,7 @@ pub(crate) fn init(linker: &mut wasmtime::Linker) -> Result<()> { let _ = mem.read( caller.as_context_mut(), path_ptr.try_into().unwrap(), - path.as_bytes_mut(), + path.as_mut_bytes(), ); let path = "/".to_owned() + std::str::from_utf8(&path).unwrap(); @@ -469,7 +469,7 @@ pub(crate) fn init(linker: &mut wasmtime::Linker) -> Result<()> { let _ = mem.read( caller.as_context(), iovs_ptr.try_into().unwrap(), - iovs.as_bytes_mut(), + iovs.as_mut_bytes(), ); let mut nread_bytes: i32 = 0; @@ -594,7 +594,7 @@ pub(crate) fn init(linker: &mut wasmtime::Linker) -> Result<()> { let _ = mem.read( caller.as_context(), iovs_ptr.try_into().unwrap(), - iovs.as_bytes_mut(), + iovs.as_mut_bytes(), ); let mut nwritten_bytes: i32 = 0;