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