To gain some experience with the new async/await and Runtime, I'm trying to extend the sample TCP proxy in the Runtime examples. The goal is to transform the received bytes before transmitting them. A simple example is capitalizing all the letters (assuming all the bytes are "letters", of course), A useful application is applying a stream cipher.
In the example, the proxying in a given direction is done in a single line via the
copy_into() function on a
copy_into() returns a future called
CopyInto--a wrapper around another future called
CopyBufInto which copies all the data from the Reader into the Writer until EOF on the Reader occurs.
One possible solution is replacing the call to
copy_into() with the creation of a custom future, modeled on
CopyBufInto, but with addiional transform logic. To get started on that, I copied the source of the CopyBufInto future into the sample. That resulted in a bunch of compilation failures that looked
tough to resolve. Before I start plowing through those: is creating a custom future a good approach to getting enhanced "copy into" functionality? Or is there some other extension mechanism?