| ... | @@ -294,7 +294,19 @@ pub fn LinearFifo( | ... | @@ -294,7 +294,19 @@ pub fn LinearFifo( |
| 294 | pub usingnamespace if (T == u8) | 294 | pub usingnamespace if (T == u8) |
| 295 | struct { | 295 | struct { |
| 296 | pub fn print(self: *Self, comptime format: []const u8, args: var) !void { | 296 | pub fn print(self: *Self, comptime format: []const u8, args: var) !void { |
| 297 | return std.fmt.format(self, error{OutOfMemory}, Self.write, format, args); | 297 | // TODO: maybe expose this stream as a method? |
| | 298 | const FifoStream = struct { |
| | 299 | const OutStream = std.io.OutStream(*Self, Error, write); |
| | 300 | const Error = error{OutOfMemory}; |
| | 301 | |
| | 302 | fn write(fifo: *Self, bytes: []const u8) Error!usize { |
| | 303 | try fifo.write(bytes); |
| | 304 | return bytes.len; |
| | 305 | } |
| | 306 | }; |
| | 307 | |
| | 308 | var out_stream = FifoStream.OutStream{ .context = self }; |
| | 309 | try out_stream.print(format, args); |
| 298 | } | 310 | } |
| 299 | } | 311 | } |
| 300 | else | 312 | else |