---
title: "Using Rust typestates for BCF writing"
url: https://daily.dev/posts/using-rust-typestates-for-bcf-writing-jnagdofxn
source_url: https://deterministic.space/seqair-bcf.html
type: article
source: "Pascal’s scribbles"
published: 2026-05-08T10:45:25.922Z
updated: 2026-05-08T10:45:49.929Z
tags: ["architecture", "rust", "biotech"]
reading_time: 15
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Rust typestates for BCF writing

**[Pascal’s scribbles](https://daily.dev/sources/deterministicspace)** · 15 min read · 0 upvotes · 0 comments

## Summary

A deep dive into using Rust typestates and phantom types to enforce compile-time correctness when writing VCF/BCF genomic data files. The author walks through a header builder with phase-based state transitions, typed keys using uninhabited enums, and a record encoder state machine — all designed to make misuse a compile error rather than a runtime bug. The post also covers benchmark results showing seqair outperforms both htslib and noodles, discusses the limits of the type system (e.g., BCF integer sentinel bugs caught only by property tests), and reflects on API design tradeoffs like key.encode() vs encoder.encode().

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://deterministic.space/seqair-bcf.html>

## Similar posts on daily.dev

- [Seqair, my Rust-native take on htslib](https://daily.dev/posts/seqair-my-rust-native-take-on-htslib-9puntghme) · Pascal’s scribbles · 0 upvotes · 0 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#rust](https://daily.dev/tags/rust), [#biotech](https://daily.dev/tags/biotech)

[View this post on daily.dev](https://daily.dev/posts/using-rust-typestates-for-bcf-writing-jnagdofxn)
