Skip to content

Commit f2140b0

Browse files
committed
feat: added allocating buffers with a warning
1 parent af3a70d commit f2140b0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/record.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ pub trait BinseqRecord {
5353
Ok(())
5454
}
5555

56+
/// Decodes the primary sequence of this record into a newly allocated buffer.
57+
///
58+
/// Not advised to use this function as it allocates a new buffer every time.
59+
fn decode_s_alloc(&self) -> Result<Vec<u8>> {
60+
let mut buf = Vec::with_capacity(self.slen() as usize);
61+
self.decode_s(&mut buf)?;
62+
Ok(buf)
63+
}
64+
65+
/// Decodes the extended sequence of this record into a newly allocated buffer.
66+
///
67+
/// Not advised to use this function as it allocates a new buffer every time.
68+
fn decode_x_alloc(&self) -> Result<Vec<u8>> {
69+
let mut buf = Vec::with_capacity(self.xlen() as usize);
70+
self.decode_x(&mut buf)?;
71+
Ok(buf)
72+
}
73+
5674
/// A convenience function to check if the record is paired.
5775
fn is_paired(&self) -> bool {
5876
self.xlen() > 0

0 commit comments

Comments
 (0)