I played around with deno_core and tried to add a tcp stream to the resource table when bootstrapping the worker. I somehow got it working, but i feel like that this is not the way to go, and just want to ask if you have better solutions for this.
What i did is basically copying https://github.com/denoland/deno/blob/main/core/examples/http_bench_json_ops.rs#L84-L117 and wrapping everything in a Rc and making it cloneable. Then i bootstrap the runtime by using my custom stream struct and cloning it into the resource table. Is this somewhat of a sensible solution?
Code can be found here: https://gist.github.com/DreamTexX/998d7ccb1664414efc7fc9b44ab6cb74
main.js looks like this:
let data = new Uint8Array(100);
await Deno.core.read(3, data);
Deno.core.print(new TextDecoder().decode(data));