Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
docs(brrrr-lib): add example for RecordWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
tshauck committed Sep 18, 2021
1 parent 31df735 commit 80a551a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions brrrr-lib/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ use serde::ser::Serialize;
use std::io::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
///
/// ```rust
/// // Given our `JsonRecordWriter`, implementing the RecordWriter means it's possible to
/// // write records in json to underlying structs that implement Write.
/// 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(())
/// }
/// }
/// ```
pub trait RecordWriter {
fn write_serde_record<S: Serialize>(&mut self, r: S) -> Result<()>;
}

0 comments on commit 80a551a

Please sign in to comment.