Skip to content

Commit ae0d1c1

Browse files
authored
refactor: add #[non_exhaustive] to public structs and enums (#8)
Prevents semver-breaking changes when adding new fields or variants to Contig, KnownReference, QueryHeader, ContigMetadata, BuilderError, and CatalogCommands.
1 parent a50a36f commit ae0d1c1

5 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/catalog/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::core::types::{Assembly, ReferenceSource};
1515
use crate::utils::validation::{is_valid_md5, is_valid_sha512t24u};
1616

1717
#[derive(Error, Debug)]
18+
#[non_exhaustive]
1819
pub enum BuilderError {
1920
#[error("IO error: {0}")]
2021
Io(#[from] std::io::Error),
@@ -101,6 +102,7 @@ impl InputFormat {
101102

102103
/// Metadata for a single contig, collected from multiple sources
103104
#[derive(Debug, Clone)]
105+
#[non_exhaustive]
104106
pub struct ContigMetadata {
105107
/// Primary name (exact, from first source)
106108
pub primary_name: String,

src/cli/catalog.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub struct CatalogArgs {
2424
}
2525

2626
#[derive(Subcommand)]
27+
#[non_exhaustive]
2728
pub enum CatalogCommands {
2829
/// List all references in the catalog
2930
List {

src/core/contig.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl SequenceRole {
4141

4242
/// A single contig/sequence in a reference genome
4343
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
44+
#[non_exhaustive]
4445
pub struct Contig {
4546
/// Sequence name (SN tag in SAM)
4647
pub name: String,

src/core/header.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn count_to_f64(count: usize) -> f64 {
1616

1717
/// A query header extracted from a BAM/SAM/CRAM file
1818
#[derive(Debug, Clone, Serialize, Deserialize)]
19+
#[non_exhaustive]
1920
pub struct QueryHeader {
2021
/// Source file path (if known)
2122
#[serde(default, skip_serializing_if = "Option::is_none")]

src/core/reference.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::utils::validation::compute_signature as compute_sig;
77

88
/// A known reference genome in the catalog
99
#[derive(Debug, Clone, Serialize, Deserialize)]
10+
#[non_exhaustive]
1011
pub struct KnownReference {
1112
/// Unique identifier
1213
pub id: ReferenceId,

0 commit comments

Comments
 (0)