Description
In order to make bindings more Go idiomatic we should make streams implement the io.Reader, io.Writer and io.Closer interfaces. This would enable more seamless integration with existing Go functions.
Example
For the following wit type stream<u8> the types should implement the following:
// StreamReader implements io.ReadCloser
var _ io.ReadCloser = (*witTypes.StreamReader[uint8])(nil)
// io.ReadCloser
type ReadCloser interface {
Read(p []byte) (n int, err error)
Close() error
}
// StreamWriter implements io.WriteCloser
var _ io.WriteCloser = (*witTypes.StreamWriter[uint8])(nil)
// io.WriteCloser
type WriteCloser interface {
Write(p []byte) (n int, err error)
Close() error
}
This would allow you to for example, encode json straight onto the stream:
// Create stream
tx, rx := foo.MakeStreamU8()
// Encode json
err := son.NewEncoder(tx).Encode(map[string]string{
"foo": "bar",
})
...
Description
In order to make bindings more Go idiomatic we should make streams implement the
io.Reader,io.Writerandio.Closerinterfaces. This would enable more seamless integration with existing Go functions.Example
For the following wit type
stream<u8>the types should implement the following:This would allow you to for example, encode json straight onto the stream: