Skip to content

Commit d249d5c

Browse files
committed
style: formatting
1 parent 84920a5 commit d249d5c

6 files changed

Lines changed: 211 additions & 211 deletions

File tree

src/error.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ pub enum Error {
2626
#[derive(thiserror::Error, Debug)]
2727
pub enum HeaderError {
2828
/// The magic number in the header does not match the expected value
29-
///
29+
///
3030
/// # Arguments
3131
/// * `u32` - The invalid magic number that was found
3232
#[error("Invalid magic number: {0}")]
3333
InvalidMagicNumber(u32),
3434

3535
/// The format version in the header is not supported
36-
///
36+
///
3737
/// # Arguments
3838
/// * `u8` - The unsupported version number that was found
3939
#[error("Invalid format version: {0}")]
@@ -44,7 +44,7 @@ pub enum HeaderError {
4444
InvalidReservedBytes,
4545

4646
/// The size of the data does not match what was specified in the header
47-
///
47+
///
4848
/// # Arguments
4949
/// * First `usize` - The actual number of bytes provided
5050
/// * Second `usize` - The expected number of bytes according to the header
@@ -60,7 +60,7 @@ pub enum ReadError {
6060
IncompatibleFile,
6161

6262
/// The file appears to be truncated or corrupted
63-
///
63+
///
6464
/// # Arguments
6565
/// * `usize` - The byte position where the truncation was detected
6666
#[error(
@@ -69,7 +69,7 @@ pub enum ReadError {
6969
FileTruncation(usize),
7070

7171
/// Attempted to access a record index that is beyond the available range
72-
///
72+
///
7373
/// # Arguments
7474
/// * First `usize` - The requested record index
7575
/// * Second `usize` - The maximum available record index
@@ -81,15 +81,15 @@ pub enum ReadError {
8181
#[derive(thiserror::Error, Debug)]
8282
pub enum WriteError {
8383
/// The length of the sequence being written does not match what was specified in the header
84-
///
84+
///
8585
/// # Fields
8686
/// * `expected` - The sequence length specified in the header
8787
/// * `got` - The actual length of the sequence being written
8888
#[error("Sequence length ({got}) does not match the header ({expected})")]
8989
UnexpectedSequenceLength { expected: u32, got: usize },
9090

9191
/// The sequence contains invalid nucleotide characters
92-
///
92+
///
9393
/// # Arguments
9494
/// * `String` - Description of the invalid nucleotides found
9595
#[error("Invalid nucleotides found in sequence: {0}")]

src/header.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ use std::io::{Read, Write};
1010
use crate::{error::Result, HeaderError};
1111

1212
/// Current magic number: "BSEQ" in ASCII (in little-endian byte order)
13-
///
13+
///
1414
/// This is used to identify binary sequence files and verify file integrity.
1515
const MAGIC: u32 = 0x51455342;
1616

1717
/// Current format version of the binary sequence file format
18-
///
18+
///
1919
/// This version number allows for future format changes while maintaining backward compatibility.
2020
const FORMAT: u8 = 1;
2121

2222
/// Size of the header in bytes
23-
///
23+
///
2424
/// The header has a fixed size to ensure consistent reading and writing of binary sequence files.
2525
pub const SIZE_HEADER: usize = 32;
2626

2727
/// Header structure for binary sequence files
28-
///
28+
///
2929
/// The `BinseqHeader` contains metadata about the binary sequence data stored in a file,
3030
/// including format information, sequence lengths, and space for future extensions.
31-
///
31+
///
3232
/// The total size of this structure is 32 bytes, with a fixed layout to ensure
3333
/// consistent reading and writing across different platforms.
3434
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -60,17 +60,17 @@ pub struct BinseqHeader {
6060
}
6161
impl BinseqHeader {
6262
/// Creates a new header with the specified sequence length
63-
///
63+
///
6464
/// This constructor initializes a standard header with the given sequence length,
6565
/// setting the magic number and format version to their default values.
6666
/// The extended sequence length (xlen) is set to 0.
67-
///
67+
///
6868
/// # Arguments
69-
///
69+
///
7070
/// * `slen` - The length of sequences in the file
71-
///
71+
///
7272
/// # Returns
73-
///
73+
///
7474
/// A new `BinseqHeader` instance
7575
pub fn new(slen: u32) -> Self {
7676
Self {
@@ -83,17 +83,17 @@ impl BinseqHeader {
8383
}
8484

8585
/// Creates a new header with both primary and extended sequence lengths
86-
///
86+
///
8787
/// This constructor initializes a header for files that contain both primary
8888
/// and secondary sequence data, such as quality scores or annotations.
89-
///
89+
///
9090
/// # Arguments
91-
///
91+
///
9292
/// * `slen` - The length of primary sequences in the file
9393
/// * `xlen` - The length of secondary/extended sequences in the file
94-
///
94+
///
9595
/// # Returns
96-
///
96+
///
9797
/// A new `BinseqHeader` instance with extended sequence information
9898
pub fn new_extended(slen: u32, xlen: u32) -> Self {
9999
Self {
@@ -106,21 +106,21 @@ impl BinseqHeader {
106106
}
107107

108108
/// Parses a header from a fixed-size byte array
109-
///
109+
///
110110
/// This method validates the magic number and format version before constructing
111111
/// a header instance. If validation fails, appropriate errors are returned.
112-
///
112+
///
113113
/// # Arguments
114-
///
114+
///
115115
/// * `buffer` - A byte array of exactly `SIZE_HEADER` bytes containing the header data
116-
///
116+
///
117117
/// # Returns
118-
///
118+
///
119119
/// * `Ok(BinseqHeader)` - A valid header parsed from the buffer
120120
/// * `Err(Error)` - If the buffer contains invalid header data
121-
///
121+
///
122122
/// # Errors
123-
///
123+
///
124124
/// Returns an error if:
125125
/// * The magic number is incorrect
126126
/// * The format version is unsupported
@@ -150,22 +150,22 @@ impl BinseqHeader {
150150
}
151151

152152
/// Parses a header from an arbitrarily sized buffer
153-
///
153+
///
154154
/// This method extracts the header from the beginning of a buffer that may be larger
155155
/// than the header size. It checks that the buffer is at least as large as the header
156156
/// before attempting to parse it.
157-
///
157+
///
158158
/// # Arguments
159-
///
159+
///
160160
/// * `buffer` - A byte slice containing at least `SIZE_HEADER` bytes
161-
///
161+
///
162162
/// # Returns
163-
///
163+
///
164164
/// * `Ok(BinseqHeader)` - A valid header parsed from the buffer
165165
/// * `Err(Error)` - If the buffer is too small or contains invalid header data
166-
///
166+
///
167167
/// # Errors
168-
///
168+
///
169169
/// Returns an error if:
170170
/// * The buffer is smaller than `SIZE_HEADER`
171171
/// * The header data is invalid (see `from_bytes` for validation details)
@@ -179,21 +179,21 @@ impl BinseqHeader {
179179
}
180180

181181
/// Writes the header to a writer
182-
///
182+
///
183183
/// This method serializes the header to its binary representation and writes it
184184
/// to the provided writer.
185-
///
185+
///
186186
/// # Arguments
187-
///
187+
///
188188
/// * `writer` - Any type that implements the `Write` trait
189-
///
189+
///
190190
/// # Returns
191-
///
191+
///
192192
/// * `Ok(())` - If the header was successfully written
193193
/// * `Err(Error)` - If writing to the writer failed
194-
///
194+
///
195195
/// # Errors
196-
///
196+
///
197197
/// Returns an error if writing to the writer fails (typically an I/O error).
198198
pub fn write_bytes<W: Write>(&self, writer: &mut W) -> Result<()> {
199199
let mut buffer = [0u8; SIZE_HEADER];
@@ -207,21 +207,21 @@ impl BinseqHeader {
207207
}
208208

209209
/// Reads a header from a reader
210-
///
210+
///
211211
/// This method reads exactly `SIZE_HEADER` bytes from the provided reader and
212212
/// parses them into a header structure.
213-
///
213+
///
214214
/// # Arguments
215-
///
215+
///
216216
/// * `reader` - Any type that implements the `Read` trait
217-
///
217+
///
218218
/// # Returns
219-
///
219+
///
220220
/// * `Ok(BinseqHeader)` - A valid header read from the reader
221221
/// * `Err(Error)` - If reading from the reader failed or the header data is invalid
222-
///
222+
///
223223
/// # Errors
224-
///
224+
///
225225
/// Returns an error if:
226226
/// * Reading from the reader fails (typically an I/O error)
227227
/// * The header data is invalid (see `from_bytes` for validation details)

src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
#![doc = include_str!("../README.md")]
2-
//!
2+
//!
33
//! # Overview
4-
//!
4+
//!
55
//! The `binseq` library provides efficient tools for working with binary-encoded
66
//! nucleotide sequences. It offers:
7-
//!
7+
//!
88
//! - Compact 2-bit encoding of nucleotide sequences
99
//! - Memory-mapped file access for efficient reading
1010
//! - Parallel processing capabilities
1111
//! - Configurable policies for handling invalid nucleotides
1212
//! - Support for both single and paired-end sequences
13-
//!
13+
//!
1414
//! # Core Components
15-
//!
15+
//!
1616
//! - [`BinseqWriter`]: Writes sequences to binary format
1717
//! - [`MmapReader`]: Reads sequences using memory mapping
1818
//! - [`BinseqHeader`]: Defines file format and sequence lengths
1919
//! - [`Policy`]: Configures invalid nucleotide handling
2020
//! - [`ParallelProcessor`]: Enables parallel sequence processing
21-
//!
21+
//!
2222
//! # Example
23-
//!
23+
//!
2424
//! ```
2525
//! use binseq::{BinseqHeader, BinseqWriterBuilder, MmapReader, Policy, Result};
2626
//! use std::io::Cursor;
27-
//!
27+
//!
2828
//! fn main() -> Result<()> {
2929
//! // Create a writer for sequences of length 100
3030
//! let header = BinseqHeader::new(100);
31-
//!
31+
//!
3232
//! let mut writer = BinseqWriterBuilder::default()
3333
//! .header(header)
3434
//! .build(Cursor::new(Vec::new()))?;
35-
//!
35+
//!
3636
//! // Write a sequence
3737
//! let sequence = b"ACGT".repeat(25); // 100 nucleotides
3838
//! writer.write_nucleotides(0, &sequence)?;
39-
//!
39+
//!
4040
//! Ok(())
4141
//! }
4242
//! ```

0 commit comments

Comments
 (0)