| 988 | #[ensures(ctx_safe(ctx))] |
| 989 | #[ensures(trace_safe(trace, ctx))] |
| 990 | pub fn write(&self, ctx: &mut VmCtx, ptr: u32) -> RuntimeResult<()> { |
| 991 | if !ctx.fits_in_lin_mem_usize(ptr as usize, Self::WASI_SIZE as usize) { |
| 992 | return Err(RuntimeError::Eoverflow); |
| 993 | } |
| 994 | |
| 995 | if !is_aligned(Alignment::Eight, ptr) { |
| 996 | return Err(RuntimeError::Einval); |
| 997 | } |
| 998 | |
| 999 | // read the subscription struct fields |
| 1000 | ctx.write_u64(ptr as usize, self.userdata); |
| 1001 | ctx.write_u16((ptr + 8) as usize, self.error.into()); |
| 1002 | ctx.write_u16((ptr + 10) as usize, self.typ.into()); |
| 1003 | if let Some(ref fd_readwrite) = self.fd_readwrite { |
| 1004 | ctx.write_u64((ptr + 16) as usize, fd_readwrite.nbytes); |
| 1005 | ctx.write_u16((ptr + 24) as usize, fd_readwrite.flags.into()); |
| 1006 | } |
| 1007 | |
| 1008 | Ok(()) |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | #[derive(Copy, Clone)] |