On further thought, you don’t seem to have done anything regarding the new writer interface yet, so here’s an explanation.
The new reader/writer interfaces are intrusive interfaces, meaning they are intended to be used as fields of the implementing type, the interface functions you implement and pass the interface field when you create your type will be given a pointer to the reader/writer. The implemented functions access the implementation state using @fieldParentPtr.
The above means you can’t copy the interface field out of the implementation type, it must be referenced by a pointer. You also can’t move the implementation while a pointer to the interface is being used, but that’s not specific to intrusive interfaces.
The new interfaces have their own state of a buffer and indexes for where in the buffer is actual data or unused space, which the implementations are expected to access and modify.
Look at std.Io.Writer.Allocating or std.fs.File.Writer for examples.
Well, I’m not really the owner of tinyvg, so heavily intrusive changes aren’t likely to get accepted.
I was really hoping for something contained. If it’s going to be that intrusive, I guess I’ll just need to file a bug and hope that the maintainer will update.
const writer = //create an instance of your writer implementation
// assumes you call the interface field `interface`
try tvg.svg.renderBinary(&writer.interface, temp_mem.allocator(), data);
remember std.Io.Writer should always be behind a pointer (except as the field of the implementation).
It’s that “create an instance of your writer implementation” that has me stumped.
I figure I’m supposed to create a writer that somehow uses the stream.context and stream.write functions, but it’s not clear at all how I’m supposed to assemble that.
I guess I’ll go poke at the std.fs.File stuff and see if I get any inspiration.