Commit 7b6ec3e354

Kenta Iwasaki <kenta@lithdew.net>
2021-05-18 10:23:59
x/os: {read, write}Vectorized() -> {read, write}Message()
1 parent 9ba6559
Changed files (4)
lib/std/x/net/tcp.zig
@@ -145,15 +145,15 @@ pub const Client = struct {
     /// Writes multiple I/O vectors with a prepended message header to the socket
     /// with a set of flags specified. It returns the number of bytes that are
     /// written to the socket.
-    pub fn writeVectorized(self: Client, msg: Socket.Message, flags: u32) !usize {
-        return self.socket.writeVectorized(msg, flags);
+    pub fn writeMessage(self: Client, msg: Socket.Message, flags: u32) !usize {
+        return self.socket.writeMessage(msg, flags);
     }
 
     /// Read multiple I/O vectors with a prepended message header from the socket
     /// with a set of flags specified. It returns the number of bytes that were
     /// read into the buffer provided.
-    pub fn readVectorized(self: Client, msg: *Socket.Message, flags: u32) !usize {
-        return self.socket.readVectorized(msg, flags);
+    pub fn readMessage(self: Client, msg: *Socket.Message, flags: u32) !usize {
+        return self.socket.readMessage(msg, flags);
     }
 
     /// 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" {
     defer conn.deinit();
 
     const message = "hello world";
-    _ = try conn.client.writeVectorized(Socket.Message.fromBuffers(&[_]Buffer{
+    _ = try conn.client.writeMessage(Socket.Message.fromBuffers(&[_]Buffer{
         Buffer.from(message[0 .. message.len / 2]),
         Buffer.from(message[message.len / 2 ..]),
     }), 0);
@@ -410,7 +410,7 @@ test "tcp/client: read and write multiple vectors" {
         Buffer.from(buf[0 .. message.len / 2]),
         Buffer.from(buf[message.len / 2 ..]),
     });
-    _ = try client.readVectorized(&msg, 0);
+    _ = try client.readMessage(&msg, 0);
 
     try testing.expectEqualStrings(message, buf[0..message.len]);
 }
lib/std/x/os/socket_posix.zig
@@ -78,14 +78,14 @@ pub fn Mixin(comptime Socket: type) type {
         /// Writes multiple I/O vectors with a prepended message header to the socket
         /// with a set of flags specified. It returns the number of bytes that are
         /// written to the socket.
-        pub fn writeVectorized(self: Socket, msg: Socket.Message, flags: u32) !usize {
+        pub fn writeMessage(self: Socket, msg: Socket.Message, flags: u32) !usize {
             return os.sendmsg(self.fd, msg, flags);
         }
 
         /// Read multiple I/O vectors with a prepended message header from the socket
         /// with a set of flags specified. It returns the number of bytes that were
         /// read into the buffer provided.
-        pub fn readVectorized(self: Socket, msg: *Socket.Message, flags: u32) !usize {
+        pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {
             while (true) {
                 const rc = os.system.recvmsg(self.fd, msg, @intCast(c_int, flags));
                 return switch (os.errno(rc)) {
lib/std/x/os/socket_windows.zig
@@ -254,7 +254,7 @@ pub fn Mixin(comptime Socket: type) type {
         /// Writes multiple I/O vectors with a prepended message header to the socket
         /// with a set of flags specified. It returns the number of bytes that are
         /// written to the socket.
-        pub fn writeVectorized(self: Socket, msg: Socket.Message, flags: u32) !usize {
+        pub fn writeMessage(self: Socket, msg: Socket.Message, flags: u32) !usize {
             const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSASENDMSG, self.fd, ws2_32.WSAID_WSASENDMSG);
 
             var num_bytes: u32 = undefined;
@@ -291,7 +291,7 @@ pub fn Mixin(comptime Socket: type) type {
         /// Read multiple I/O vectors with a prepended message header from the socket
         /// with a set of flags specified. It returns the number of bytes that were
         /// read into the buffer provided.
-        pub fn readVectorized(self: Socket, msg: *Socket.Message, flags: u32) !usize {
+        pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {
             const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG);
 
             var num_bytes: u32 = undefined;
lib/std/json.zig
@@ -2111,10 +2111,7 @@ test "parse into struct with duplicate field" {
     const ballast = try testing.allocator.alloc(u64, 1);
     defer testing.allocator.free(ballast);
 
-    const options_first = ParseOptions{
-        .allocator = testing.allocator,
-        .duplicate_field_behavior = .UseFirst,
-    };
+    const options_first = ParseOptions{ .allocator = testing.allocator, .duplicate_field_behavior = .UseFirst };
 
     const options_last = ParseOptions{
         .allocator = testing.allocator,