Is there anyway to do this? I would like to test out my event loop and have mocked out most of the external things. One part that is catching me is I wouod like to create a programmable resource that is pollable? Is it possible? If not I will just mock that as well
This sort of depends to the degree to which you're mocking. Arbitrary host resources can be made at any time with Resource::new_{own,borrow}
, all you need is a 32-bit number to put in there. If that number never ends up being used, for example the resource is never passed to wasi:io/poll
, then it doesn't matter too much what the number is. If you want to create an arbitrary real pollable resource then you'll need to use the same pollable type as wasmtime-wasi
, and the crate isn't 100% built for mocking but it should be possible since I think that one is trait-based.
For guest-defined resources there's no way to mock those out, they have to come from the guest
Alex Crichton said:
This sort of depends to the degree to which you're mocking. Arbitrary host resources can be made at any time with
Resource::new_{own,borrow}
, all you need is a 32-bit number to put in there. If that number never ends up being used, for example the resource is never passed towasi:io/poll
, then it doesn't matter too much what the number is. If you want to create an arbitrary real pollable resource then you'll need to use the same pollable type aswasmtime-wasi
, and the crate isn't 100% built for mocking but it should be possible since I think that one is trait-based.For guest-defined resources there's no way to mock those out, they have to come from the guest
Awesome this worked out well for me thank you!
Last updated: Nov 22 2024 at 17:03 UTC