authorgravatar for kenta@lithdew.netKenta Iwasaki <kenta@lithdew.net> 2021-05-18 17:23:59+09:00
committergravatar for kenta@lithdew.netKenta Iwasaki <kenta@lithdew.net> 2021-06-01 18:23:54+09:00
log7b6ec3e3548dadc597b6aa396d70ba4c6595da26
tree729277affbd435d8fa8e90e5e460af63ae6f82af
parent9ba65592d64f53d886b00402659cfce775ea77d3

x/os: {read, write}Vectorized() -> {read, write}Message()


4 files changed, 11 insertions(+), 14 deletions(-)

lib/std/json.zig+1-4
......@@ -2111,10 +2111,7 @@ test "parse into struct with duplicate field" {
21112111 const ballast = try testing.allocator.alloc(u64, 1);
21122112 defer testing.allocator.free(ballast);
21132113
2114 const options_first = ParseOptions{
2115 .allocator = testing.allocator,
2116 .duplicate_field_behavior = .UseFirst,
2117 };
2114 const options_first = ParseOptions{ .allocator = testing.allocator, .duplicate_field_behavior = .UseFirst };
21182115
21192116 const options_last = ParseOptions{
21202117 .allocator = testing.allocator,
lib/std/x/net/tcp.zig+6-6
......@@ -145,15 +145,15 @@ pub const Client = struct {
145145 /// Writes multiple I/O vectors with a prepended message header to the socket
146146 /// with a set of flags specified. It returns the number of bytes that are
147147 /// written to the socket.
148 pub fn writeVectorized(self: Client, msg: Socket.Message, flags: u32) !usize {
149 return self.socket.writeVectorized(msg, flags);
148 pub fn writeMessage(self: Client, msg: Socket.Message, flags: u32) !usize {
149 return self.socket.writeMessage(msg, flags);
150150 }
151151
152152 /// Read multiple I/O vectors with a prepended message header from the socket
153153 /// with a set of flags specified. It returns the number of bytes that were
154154 /// read into the buffer provided.
155 pub fn readVectorized(self: Client, msg: *Socket.Message, flags: u32) !usize {
156 return self.socket.readVectorized(msg, flags);
155 pub fn readMessage(self: Client, msg: *Socket.Message, flags: u32) !usize {
156 return self.socket.readMessage(msg, flags);
157157 }
158158
159159 /// Query and return the latest cached error on the client's underlying socket.
......@@ -400,7 +400,7 @@ test "tcp/client: read and write multiple vectors" {
400400 defer conn.deinit();
401401
402402 const message = "hello world";
403 _ = try conn.client.writeVectorized(Socket.Message.fromBuffers(&[_]Buffer{
403 _ = try conn.client.writeMessage(Socket.Message.fromBuffers(&[_]Buffer{
404404 Buffer.from(message[0 .. message.len / 2]),
405405 Buffer.from(message[message.len / 2 ..]),
406406 }), 0);
......@@ -410,7 +410,7 @@ test "tcp/client: read and write multiple vectors" {
410410 Buffer.from(buf[0 .. message.len / 2]),
411411 Buffer.from(buf[message.len / 2 ..]),
412412 });
413 _ = try client.readVectorized(&msg, 0);
413 _ = try client.readMessage(&msg, 0);
414414
415415 try testing.expectEqualStrings(message, buf[0..message.len]);
416416}
lib/std/x/os/socket_posix.zig+2-2
......@@ -78,14 +78,14 @@ pub fn Mixin(comptime Socket: type) type {
7878 /// Writes multiple I/O vectors with a prepended message header to the socket
7979 /// with a set of flags specified. It returns the number of bytes that are
8080 /// written to the socket.
81 pub fn writeVectorized(self: Socket, msg: Socket.Message, flags: u32) !usize {
81 pub fn writeMessage(self: Socket, msg: Socket.Message, flags: u32) !usize {
8282 return os.sendmsg(self.fd, msg, flags);
8383 }
8484
8585 /// Read multiple I/O vectors with a prepended message header from the socket
8686 /// with a set of flags specified. It returns the number of bytes that were
8787 /// read into the buffer provided.
88 pub fn readVectorized(self: Socket, msg: *Socket.Message, flags: u32) !usize {
88 pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {
8989 while (true) {
9090 const rc = os.system.recvmsg(self.fd, msg, @intCast(c_int, flags));
9191 return switch (os.errno(rc)) {
lib/std/x/os/socket_windows.zig+2-2
......@@ -254,7 +254,7 @@ pub fn Mixin(comptime Socket: type) type {
254254 /// Writes multiple I/O vectors with a prepended message header to the socket
255255 /// with a set of flags specified. It returns the number of bytes that are
256256 /// written to the socket.
257 pub fn writeVectorized(self: Socket, msg: Socket.Message, flags: u32) !usize {
257 pub fn writeMessage(self: Socket, msg: Socket.Message, flags: u32) !usize {
258258 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSASENDMSG, self.fd, ws2_32.WSAID_WSASENDMSG);
259259
260260 var num_bytes: u32 = undefined;
......@@ -291,7 +291,7 @@ pub fn Mixin(comptime Socket: type) type {
291291 /// Read multiple I/O vectors with a prepended message header from the socket
292292 /// with a set of flags specified. It returns the number of bytes that were
293293 /// read into the buffer provided.
294 pub fn readVectorized(self: Socket, msg: *Socket.Message, flags: u32) !usize {
294 pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {
295295 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG);
296296
297297 var num_bytes: u32 = undefined;