| ... | @@ -291,24 +291,16 @@ pub fn LinearFifo( | ... | @@ -291,24 +291,16 @@ pub fn LinearFifo( |
| 291 | return self.writeAssumeCapacity(src); | 291 | return self.writeAssumeCapacity(src); |
| 292 | } | 292 | } |
| 293 | | 293 | |
| 294 | pub usingnamespace if (T == u8) | 294 | /// Same as `write` except it returns the number of bytes written, which is always the same |
| 295 | struct { | 295 | /// as `bytes.len`. The purpose of this function existing is to match `std.io.OutStream` API. |
| 296 | const OutStream = std.io.OutStream(*Self, Error, appendWrite); | 296 | fn appendWrite(self: *Self, bytes: []const u8) error{OutOfMemory}!usize { |
| 297 | const Error = error{OutOfMemory}; | 297 | try self.write(bytes); |
| 298 | | 298 | return bytes.len; |
| 299 | /// Same as `write` except it returns the number of bytes written, which is always the same | 299 | } |
| 300 | /// as `bytes.len`. The purpose of this function existing is to match `std.io.OutStream` API. | | |
| 301 | pub fn appendWrite(fifo: *Self, bytes: []const u8) Error!usize { | | |
| 302 | try fifo.write(bytes); | | |
| 303 | return bytes.len; | | |
| 304 | } | | |
| 305 | | 300 | |
| 306 | pub fn outStream(self: *Self) OutStream { | 301 | pub fn outStream(self: *Self) std.io.OutStream(*Self, error{OutOfMemory}, appendWrite) { |
| 307 | return .{ .context = self }; | 302 | return .{ .context = self }; |
| 308 | } | 303 | } |
| 309 | } | | |
| 310 | else | | |
| 311 | struct {}; | | |
| 312 | | 304 | |
| 313 | /// Make `count` items available before the current read location | 305 | /// Make `count` items available before the current read location |
| 314 | fn rewind(self: *Self, count: usize) void { | 306 | fn rewind(self: *Self, count: usize) void { |