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" {...@@ -2111,10 +2111,7 @@ test "parse into struct with duplicate field" {
2111 const ballast = try testing.allocator.alloc(u64, 1);2111 const ballast = try testing.allocator.alloc(u64, 1);
2112 defer testing.allocator.free(ballast);2112 defer testing.allocator.free(ballast);
21132113
2114 const options_first = ParseOptions{2114 const options_first = ParseOptions{ .allocator = testing.allocator, .duplicate_field_behavior = .UseFirst };
2115 .allocator = testing.allocator,
2116 .duplicate_field_behavior = .UseFirst,
2117 };
21182115
2119 const options_last = ParseOptions{2116 const options_last = ParseOptions{
2120 .allocator = testing.allocator,2117 .allocator = testing.allocator,
lib/std/x/net/tcp.zig+6-6
...@@ -145,15 +145,15 @@ pub const Client = struct {...@@ -145,15 +145,15 @@ pub const Client = struct {
145 /// Writes multiple I/O vectors with a prepended message header to the socket145 /// Writes multiple I/O vectors with a prepended message header to the socket
146 /// with a set of flags specified. It returns the number of bytes that are146 /// with a set of flags specified. It returns the number of bytes that are
147 /// written to the socket.147 /// written to the socket.
148 pub fn writeVectorized(self: Client, msg: Socket.Message, flags: u32) !usize {148 pub fn writeMessage(self: Client, msg: Socket.Message, flags: u32) !usize {
149 return self.socket.writeVectorized(msg, flags);149 return self.socket.writeMessage(msg, flags);
150 }150 }
151151
152 /// Read multiple I/O vectors with a prepended message header from the socket152 /// Read multiple I/O vectors with a prepended message header from the socket
153 /// with a set of flags specified. It returns the number of bytes that were153 /// with a set of flags specified. It returns the number of bytes that were
154 /// read into the buffer provided.154 /// read into the buffer provided.
155 pub fn readVectorized(self: Client, msg: *Socket.Message, flags: u32) !usize {155 pub fn readMessage(self: Client, msg: *Socket.Message, flags: u32) !usize {
156 return self.socket.readVectorized(msg, flags);156 return self.socket.readMessage(msg, flags);
157 }157 }
158158
159 /// Query and return the latest cached error on the client's underlying socket.159 /// 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" {...@@ -400,7 +400,7 @@ test "tcp/client: read and write multiple vectors" {
400 defer conn.deinit();400 defer conn.deinit();
401401
402 const message = "hello world";402 const message = "hello world";
403 _ = try conn.client.writeVectorized(Socket.Message.fromBuffers(&[_]Buffer{403 _ = try conn.client.writeMessage(Socket.Message.fromBuffers(&[_]Buffer{
404 Buffer.from(message[0 .. message.len / 2]),404 Buffer.from(message[0 .. message.len / 2]),
405 Buffer.from(message[message.len / 2 ..]),405 Buffer.from(message[message.len / 2 ..]),
406 }), 0);406 }), 0);
...@@ -410,7 +410,7 @@ test "tcp/client: read and write multiple vectors" {...@@ -410,7 +410,7 @@ test "tcp/client: read and write multiple vectors" {
410 Buffer.from(buf[0 .. message.len / 2]),410 Buffer.from(buf[0 .. message.len / 2]),
411 Buffer.from(buf[message.len / 2 ..]),411 Buffer.from(buf[message.len / 2 ..]),
412 });412 });
413 _ = try client.readVectorized(&msg, 0);413 _ = try client.readMessage(&msg, 0);
414414
415 try testing.expectEqualStrings(message, buf[0..message.len]);415 try testing.expectEqualStrings(message, buf[0..message.len]);
416}416}
lib/std/x/os/socket_posix.zig+2-2
...@@ -78,14 +78,14 @@ pub fn Mixin(comptime Socket: type) type {...@@ -78,14 +78,14 @@ pub fn Mixin(comptime Socket: type) type {
78 /// Writes multiple I/O vectors with a prepended message header to the socket78 /// Writes multiple I/O vectors with a prepended message header to the socket
79 /// with a set of flags specified. It returns the number of bytes that are79 /// with a set of flags specified. It returns the number of bytes that are
80 /// written to the socket.80 /// 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 {
82 return os.sendmsg(self.fd, msg, flags);82 return os.sendmsg(self.fd, msg, flags);
83 }83 }
8484
85 /// Read multiple I/O vectors with a prepended message header from the socket85 /// Read multiple I/O vectors with a prepended message header from the socket
86 /// with a set of flags specified. It returns the number of bytes that were86 /// with a set of flags specified. It returns the number of bytes that were
87 /// read into the buffer provided.87 /// 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 {
89 while (true) {89 while (true) {
90 const rc = os.system.recvmsg(self.fd, msg, @intCast(c_int, flags));90 const rc = os.system.recvmsg(self.fd, msg, @intCast(c_int, flags));
91 return switch (os.errno(rc)) {91 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 {...@@ -254,7 +254,7 @@ pub fn Mixin(comptime Socket: type) type {
254 /// Writes multiple I/O vectors with a prepended message header to the socket254 /// Writes multiple I/O vectors with a prepended message header to the socket
255 /// with a set of flags specified. It returns the number of bytes that are255 /// with a set of flags specified. It returns the number of bytes that are
256 /// written to the socket.256 /// 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 {
258 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSASENDMSG, self.fd, ws2_32.WSAID_WSASENDMSG);258 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSASENDMSG, self.fd, ws2_32.WSAID_WSASENDMSG);
259259
260 var num_bytes: u32 = undefined;260 var num_bytes: u32 = undefined;
...@@ -291,7 +291,7 @@ pub fn Mixin(comptime Socket: type) type {...@@ -291,7 +291,7 @@ pub fn Mixin(comptime Socket: type) type {
291 /// Read multiple I/O vectors with a prepended message header from the socket291 /// Read multiple I/O vectors with a prepended message header from the socket
292 /// with a set of flags specified. It returns the number of bytes that were292 /// with a set of flags specified. It returns the number of bytes that were
293 /// read into the buffer provided.293 /// 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 {
295 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG);295 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG);
296296
297 var num_bytes: u32 = undefined;297 var num_bytes: u32 = undefined;