From c3bb814d465d0bcddb9c8d39cfe301040978e243 Mon Sep 17 00:00:00 2001 From: Michael Macias Date: Mon, 1 Jul 2024 10:50:29 -0500 Subject: [PATCH] bed/io/writer/record: Add other field writer --- noodles-bed/src/io/writer/record.rs | 5 ++++- noodles-bed/src/io/writer/record/other_fields.rs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 noodles-bed/src/io/writer/record/other_fields.rs diff --git a/noodles-bed/src/io/writer/record.rs b/noodles-bed/src/io/writer/record.rs index 8046a6761..a45fa9f06 100644 --- a/noodles-bed/src/io/writer/record.rs +++ b/noodles-bed/src/io/writer/record.rs @@ -1,12 +1,13 @@ mod feature_end; mod feature_start; +mod other_fields; mod reference_sequence_name; use std::io::{self, Write}; use self::{ feature_end::write_feature_end, feature_start::write_feature_start, - reference_sequence_name::write_reference_sequence_name, + other_fields::write_other_fields, reference_sequence_name::write_reference_sequence_name, }; use crate::Record; @@ -25,6 +26,8 @@ where let feature_end = record.feature_end()?; write_feature_end(writer, feature_end)?; + write_other_fields(writer, record.other_fields())?; + write_newline(writer)?; Ok(()) diff --git a/noodles-bed/src/io/writer/record/other_fields.rs b/noodles-bed/src/io/writer/record/other_fields.rs new file mode 100644 index 000000000..3211cd788 --- /dev/null +++ b/noodles-bed/src/io/writer/record/other_fields.rs @@ -0,0 +1,16 @@ +use std::io::{self, Write}; + +use super::write_separator; +use crate::record::OtherFields; + +pub(super) fn write_other_fields(writer: &mut W, other_fields: OtherFields<'_>) -> io::Result<()> +where + W: Write, +{ + for field in other_fields.iter() { + write_separator(writer)?; + writer.write_all(field)?; + } + + Ok(()) +}