tried to port this to zig v0.16
but i am stuck with these two lines:
https://github.com/ikskuh/zig-bearssl/blob/master/src/binding.zig#L699
const read_result = input.read(buf[0..len]) catch return -1;
https://github.com/ikskuh/zig-bearssl/blob/master/src/binding.zig#L707
const write_result = output.write(buf[0..len]) catch return -1;
in zig v0.16
input and output are both Io.net.Socket instances in the
functions sockRead() and sockWrite() respectively. These functions
are called from inside the bearssl c code, to get data from/to the
socket. Now with the IOcalypse, sockets have their function names
changed from read/write to receive/send and - here's my blocking issue
- they now demand an std.Io parameter.
i came up with two ugly workarounds:
-
add a global std.Io variable in this module which gets set when calling Stream.init().
i suspect this might mess with multithreading?
-
just use the .handle variable of the socket, and directly call
posix.system.(write|read)(socket.handle, buf[0..], buf.len)
which eliminates some portability i suppose?
i'm gonna go for 2. but feel bad about it. maybe you have a better solution?
i'll open a PR as soon as i have a working port to 0.16, up to you if you accept my ugly workaround or maybe you teach me something better :)
tried to port this to zig v0.16
but i am stuck with these two lines:
https://github.com/ikskuh/zig-bearssl/blob/master/src/binding.zig#L699
https://github.com/ikskuh/zig-bearssl/blob/master/src/binding.zig#L707
in zig v0.16
inputandoutputare bothIo.net.Socketinstances in thefunctions
sockRead()andsockWrite()respectively. These functionsare called from inside the bearssl c code, to get data from/to the
socket. Now with the IOcalypse, sockets have their function names
changed from read/write to receive/send and - here's my blocking issue
i came up with two ugly workarounds:
add a global std.Io variable in this module which gets set when calling Stream.init().
i suspect this might mess with multithreading?
just use the .handle variable of the socket, and directly call
posix.system.(write|read)(socket.handle, buf[0..], buf.len)which eliminates some portability i suppose?
i'm gonna go for 2. but feel bad about it. maybe you have a better solution?
i'll open a PR as soon as i have a working port to 0.16, up to you if you accept my ugly workaround or maybe you teach me something better :)