output/ndjson.rs
1//! One JSON object per line (NDJSON).
2
3use crate::FileRecord;
4use std::io::{self, Write};
5
6/// Serialize `record` as a single JSON line (no trailing newline).
7pub fn write_record<W: Write>(writer: &mut W, record: &FileRecord) -> io::Result<()> {
8 serde_json::to_writer(writer, record).map_err(io::Error::other)
9}
10
11/// Same as [`write_record`] then append `\n`.
12pub fn write_record_line<W: Write>(writer: &mut W, record: &FileRecord) -> io::Result<()> {
13 write_record(writer, record)?;
14 writer.write_all(b"\n")
15}