1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// (c) Copyright 2020 Trent Hauck
// All Rights Reserved
use Serialize;
use Result;
/// A RecordWriter writes FASTA records to the underlying source.
///
/// Implement this trait in order to read bioinformatic formats and write it the paricular
/// underlying format.
///
/// # Examples
///
/// ```ignore
/// // Given our `JsonRecordWriter`, implementing the RecordWriter means it's possible to
/// // write records in json to underlying structs that implement Write.
///
/// use serde::Serialize;
///
/// use std::io::Result;
/// use std::io::Write;
///
/// use brrrr_lib::writer;
///
/// impl<W: Write> writer::RecordWriter for JsonRecordWriter<W> {
/// fn write_serde_record<S: Serialize>(&mut self, r: S) -> Result<()> {
/// serde_json::to_writer(&mut self.writer, &r)?;
/// self.writer.write_all(b"\n")?;
///
/// Ok(())
/// }
/// }
/// ```