| ... | @@ -27,14 +27,16 @@ pub fn read(self: File, buffer: []u8) ReadError!usize { | ... | @@ -27,14 +27,16 @@ pub fn read(self: File, buffer: []u8) ReadError!usize { |
| 27 | | 27 | |
| 28 | pub fn anyReadable(self: File) nio.AnyReadable { | 28 | pub fn anyReadable(self: File) nio.AnyReadable { |
| 29 | const S = struct { | 29 | const S = struct { |
| 30 | fn foo(s: *allowzero anyopaque, buffer: []u8) anyerror!usize { | 30 | fn read(s: *allowzero anyopaque, buffer: []u8) anyerror!usize { |
| 31 | const fd: nfs.Handle = @enumFromInt(@intFromPtr(s)); | 31 | const fd: nfs.Handle = @enumFromInt(@intFromPtr(s)); |
| 32 | const f: File = .{ .fd = fd }; | 32 | const f: File = .{ .fd = fd }; |
| 33 | return f.read(buffer); | 33 | return f.read(buffer); |
| 34 | } | 34 | } |
| 35 | }; | 35 | }; |
| 36 | return .{ | 36 | return .{ |
| 37 | .readFn = S.foo, | 37 | .vtable = &.{ |
| | 38 | .read = S.read, |
| | 39 | }, |
| 38 | .state = @ptrFromInt(@as(usize, @bitCast(@as(isize, @intCast(@intFromEnum(self.fd)))))), | 40 | .state = @ptrFromInt(@as(usize, @bitCast(@as(isize, @intCast(@intFromEnum(self.fd)))))), |
| 39 | }; | 41 | }; |
| 40 | } | 42 | } |