MinusGix opened issue #8274:
Feature
When supplying a custom
MemoryInputPipe
toWasiCtxBuilder
asstdin
it would be useful to have the ability to write to it in order to communicate with the program.(The specific use-case here is spawning WASM programs that essentially act like LSPs, communicating over a simple text interface rather than directly calling functions)
Benefit
Allows sending data through stdin, and reading data from stdout/stderr.
Implementation
Probably have to change
MemoryInputPipe
to use aBytesMut
.
Could add standardstd::io::Read
/std::io::Write
implementations toMemoryInputPipe
(andMemoryOutputPipe
, though that's readable though.content()
) like the oldReadPipe
/WritePipe
from wasi-common?Alternatives
Reimplement a version locally.
(Could be I've missed some alternative solution?)
MinusGix edited issue #8274:
Feature
When supplying a custom
MemoryInputPipe
toWasiCtxBuilder
asstdin
it would be useful to have the ability to write to it in order to communicate with the program.(The specific use-case here is spawning WASM programs that essentially act like LSPs, communicating over a simple text interface rather than directly calling functions)
Benefit
Allows sending data through stdin, along with reading data from stdout/stderr.
Implementation
Probably have to change
MemoryInputPipe
to use aBytesMut
.
Could add standardstd::io::Read
/std::io::Write
implementations toMemoryInputPipe
(andMemoryOutputPipe
, though that's readable though.content()
) like the oldReadPipe
/WritePipe
from wasi-common?Alternatives
Reimplement a version locally.
(Could be I've missed some alternative solution?)
bjorn3 commented on issue #8274:
Would
wasmtime_wasi::pipe::AsyncReadStream
work for you? It allows the guest to read from anAsyncRead
you supply.
alexcrichton commented on issue #8274:
To confirm, @MinusGix are you using the C API? If so then this implemented in the C API at this time. If you're using the Rust API, however, you can use
WasiCtxBuilder::stdin
with a custom implementation ofStdinStream
where theHostInputStream
you're implementing would be backed byAsyncReadStream
as @bjorn3 mentioned.
MinusGix commented on issue #8274:
I am using the Rust API, updating a project that was last on 14.0.0.
I have not directly used async/tokio much in any past projects, which makes it unclear what type to use that implements
AsyncRead
+ can be shared so that we can write to it from elsewhere. If there's some obvious choice here, I was unable to find it after some searching on the net/tokio docs.If I'm needing a custom implementation, then it seems simpler to reuse a modified
MemoryInputStream
to implementWrite
(and if provided in wasmtime would make it simpler as a user).
alexcrichton commented on issue #8274:
I think what you probably want is a
DuplexStream
MinusGix closed issue #8274:
Feature
When supplying a custom
MemoryInputPipe
toWasiCtxBuilder
asstdin
it would be useful to have the ability to write to it in order to communicate with the program.(The specific use-case here is spawning WASM programs that essentially act like LSPs, communicating over a simple text interface rather than directly calling functions)
Benefit
Allows sending data through stdin, along with reading data from stdout/stderr.
Implementation
Probably have to change
MemoryInputPipe
to use aBytesMut
.
Could add standardstd::io::Read
/std::io::Write
implementations toMemoryInputPipe
(andMemoryOutputPipe
, though that's readable though.content()
) like the oldReadPipe
/WritePipe
from wasi-common?Alternatives
Reimplement a version locally.
(Could be I've missed some alternative solution?)
MinusGix commented on issue #8274:
That'll probably work.
Looking back, the primary issue is seemingly that I was confused aboutMemoryInputPipe
/MemoryOutputPipe
: I was interpreting them as "buffers to read/write from which are just missing utility functions", but they're actually for having some fixed data that you want to pass in or having a fixed size buffer to write data into.
Last updated: Dec 23 2024 at 12:05 UTC