| 372 | |
| 373 | impl<W: Write> VertexBuffer for ConflictWriter<W> { |
| 374 | fn output_line<E, F>(&mut self, node: GraphNode<NodeId>, get_contents: F) -> Result<(), E> |
| 375 | where |
| 376 | E: From<std::io::Error>, |
| 377 | F: FnOnce(&mut [u8]) -> Result<(), E>, |
| 378 | { |
| 379 | // Calculate node length |
| 380 | let len = (node.end.get() - node.start.get()) as usize; |
| 381 | if len == 0 { |
| 382 | return Ok(()); |
| 383 | } |
| 384 | |
| 385 | // Resize buffer and get contents |
| 386 | self.content_buffer.clear(); |
| 387 | self.content_buffer.resize(len, 0); |
| 388 | get_contents(&mut self.content_buffer)?; |
| 389 | |
| 390 | // Track line endings |
| 391 | let ends_with_newline = self.content_buffer.ends_with(b"\n"); |
| 392 | self.line += Self::count_newlines(&self.content_buffer); |
| 393 | |
| 394 | // Write to underlying writer |
| 395 | self.writer.write_all(&self.content_buffer)?; |
| 396 | self.bytes_written += len as u64; |
| 397 | |
| 398 | // Update line start tracking |
| 399 | if !self.content_buffer.is_empty() { |
| 400 | self.at_line_start = ends_with_newline; |
| 401 | } |
| 402 | |
| 403 | Ok(()) |
| 404 | } |
| 405 | |
| 406 | fn output_conflict_marker( |
| 407 | &mut self, |