Expand description
§fits-header
A pure-Rust, MSVC-safe library for reading and writing the header of a FITS file.
It reads a header unit into an ordered Header of records, retaining every card so untouched
cards serialize byte-for-byte and only created or modified cards are re-rendered. Access is
strict and keyword-oriented: Header::get and friends take a Key that is either a bare
name (unique-or-FitsError::AmbiguousKeyword) or (name, occurrence). Values read through a
generic FromCard and write through IntoValue; batch edits are atomic; long strings use
the CONTINUE convention.
use fits_header::Header;
let mut h = Header::new();
h.set("OBJECT", "M31").unwrap();
h.set("EXPTIME", 120.0).unwrap();
assert_eq!(h.get::<f64>("EXPTIME").unwrap(), Some(120.0));
// The header block only — creating a file means appending your own pixel data after
// this; editing an existing file means Header::update_file, which preserves it.
let bytes = h.to_header_bytes();
assert_eq!(bytes.len() % fits_header::BLOCK_LEN, 0);§Design
- Pure Rust, no C or system libraries; builds with the MSVC toolchain.
- An untouched card (and untouched long-string run) re-emits identical bytes.
- Ambiguous keyword access errors instead of guessing.
§Features
serde(off) — deriveSerialize/Deserializeon the public types.
Structs§
- Fixed
- Write a float with a fixed number of decimal places.
- Header
- An ordered FITS header unit:
Records in appearance order, with strict keyword access (viaKey) and CRUD. - Literal
- Write a literal token verbatim (numeric text a vendor supplied, or a value you don’t want reformatted).
- Record
- One header card. Carries its parsed
RecordKindplus, when parsed and unmodified, the original bytes of its physical card(s) so it can be serialized verbatim. - Sci
- Write a float in scientific notation with
Nsignificant digits (uppercaseE).
Enums§
- Fits
Error - Errors from validated header mutations, ambiguous lookups, and oversized standalone serialization.
- Key
- Selects a record by keyword.
- Record
Kind - The semantic content of a
Record. - Value
- A value card’s payload.
Constants§
Traits§
- From
Card - Convert a record’s value into a Rust type. The extension point behind
Header::get. - Into
Value - Convert a Rust value into a
Value. The extension point behindHeader::set/append.
Functions§
- format_
datetime - Format a date/time back to the FITS civil form (
YYYY-MM-DDThh:mm:ss[.fff]), dropping a zero sub-second part. - parse
Deprecated - Deprecated free-function alias for
Header::parse; use that instead. - parse_
datetime - Parse a FITS civil date/time (
YYYY-MM-DD[Thh:mm:ss[.fff]]), timezone-naive. - parse_
f64 - Parse a float, accepting the Fortran
Dexponent (1.5D3). - parse_
i64 - Parse an integer, accepting decimal-form integers (
"20.0"→20).