You got the wrong userdata. Basically you are passing pointer to your own Writer interface, to the underlying writer which expects pointer to its own Writer interface. Should be
const n = try self.inner.vtable.drain(self.inner, data, splat);
Otherwise looking good. Took me a while to spot the issue.
Thanks @psznm , @xeubie and @lalinsky for all the good examples and advices. I’ll mark this as solution, because its working code; so anyone who is looking to solve a similar task finds it. But of course, I would not have worked it out (this fast or maybe ever?) without help of the named users!!
I took the inspirations and tipps from this thread and implemented wrapping Reader and Writer for the http requests of the S3 lib z3. I hope this is might help somebody who has a similar task to solve. And of course thanks again to anybody who answered in this thread!