pub struct Header { /* private fields */ }Expand description
A parsed header unit: an ordered list of content cards plus a side index for O(1) keyword lookup.
Order and duplicates are preserved exactly (commentary cards repeat, and
record order is significant), so the model is a vector — never a map. The
terminating END record is implicit and not stored as a card. Long-string
values split across CONTINUE records are reassembled into a single value
card on read and re-emitted as a canonical CONTINUE chain on write, so the
round-trip preserves the logical model (not necessarily the original byte
split).
Implementations§
Source§impl Header
impl Header
Sourcepub fn parse(bytes: &[u8]) -> Result<Header>
pub fn parse(bytes: &[u8]) -> Result<Header>
Parse a header unit from its raw bytes (a whole number of 80-byte cards;
the reader supplies block-aligned input). Stops at the END record.
Sourcepub fn get(&self, keyword: &str) -> Option<&Value>
pub fn get(&self, keyword: &str) -> Option<&Value>
The value of the first card with this keyword, if it is a valued card.
pub fn get_logical(&self, keyword: &str) -> Option<bool>
pub fn get_integer(&self, keyword: &str) -> Option<i64>
pub fn get_real(&self, keyword: &str) -> Option<f64>
pub fn get_text(&self, keyword: &str) -> Option<&str>
Sourcepub fn iter(&self) -> impl Iterator<Item = HeaderEntry<'_>>
pub fn iter(&self) -> impl Iterator<Item = HeaderEntry<'_>>
Every stored record in file order, as HeaderEntry views — duplicates and
order preserved (the whole point of the ordered model), so COMMENT/HISTORY
runs and repeated keywords come through intact. The implicit END is not a
record and is never yielded. For valued keywords only, filter on
e.value: header.iter().filter_map(|e| Some((e.keyword, e.value?))).
Sourcepub fn scaling(&self) -> Scaling
pub fn scaling(&self) -> Scaling
The physical-value scaling (BSCALE/BZERO/BLANK) declared by this header.
Sourcepub fn wcs(&self, alt: Option<char>) -> Result<Wcs>
pub fn wcs(&self, alt: Option<char>) -> Result<Wcs>
Parse the World Coordinate System (FITS §8) described by this header: the
primary description (alt = None) or an alternate (alt = Some('A'..='Z')).
Sourcepub fn wcs_pixel_list(
&self,
columns: &[usize],
alt: Option<char>,
) -> Result<Wcs>
pub fn wcs_pixel_list( &self, columns: &[usize], alt: Option<char>, ) -> Result<Wcs>
WCS for a pixel-list table (§8.4.2), where the given columns hold the
coordinate axes; alt selects the primary (None) or an alternate system.
Sourcepub fn wcs_array_column(&self, column: usize, alt: Option<char>) -> Result<Wcs>
pub fn wcs_array_column(&self, column: usize, alt: Option<char>) -> Result<Wcs>
WCS attached to a single array-valued table column (§8.4.1).
Sourcepub fn time(&self) -> FitsTime
pub fn time(&self) -> FitsTime
The time-coordinate frame (FITS §9) parsed from this header — reference epoch/scale, units, and any time WCS axis.
Sourcepub fn obs_mjd(&self) -> Option<f64>
pub fn obs_mjd(&self) -> Option<f64>
The observation Modified Julian Date — MJD-OBS, else DATE-OBS, else the
JEPOCH/BEPOCH epoch, else None.
Sourcepub fn epoch(&self) -> Option<EpochTime>
pub fn epoch(&self) -> Option<EpochTime>
The Julian (JEPOCH) or Besselian (BEPOCH) epoch keyword, if present.
Sourcepub fn time_bounds(&self) -> TimeBounds
pub fn time_bounds(&self) -> TimeBounds
The observation time bounds (start/end/duration, §9.2.3) from this header.
Sourcepub fn phase_axis(&self, axis: usize) -> Option<PhaseAxis>
pub fn phase_axis(&self, axis: usize) -> Option<PhaseAxis>
The §9.6 'PHASE' axis parameters for WCS axis (1-based), if it is one.
Sourcepub fn new() -> Header
pub fn new() -> Header
Create an empty header. Build it up with Header::set and friends.
Sourcepub fn set(&mut self, keyword: &str, value: impl Into<Value>) -> &mut Self
pub fn set(&mut self, keyword: &str, value: impl Into<Value>) -> &mut Self
Insert a valued keyword, or replace the value of an existing one, keeping
the keyword index in sync. Returns &mut self for chaining. The keyword
must be a valid FITS keyword name (≤ 8 chars of A–Z, 0–9, -, _).
Sourcepub fn comment(&mut self, keyword: &str, text: &str) -> &mut Self
pub fn comment(&mut self, keyword: &str, text: &str) -> &mut Self
Attach (or replace) the inline comment of an existing valued keyword; a no-op if the keyword is absent.
Sourcepub fn push_comment(&mut self, text: &str) -> &mut Self
pub fn push_comment(&mut self, text: &str) -> &mut Self
Append a COMMENT card.
Sourcepub fn push_history(&mut self, text: &str) -> &mut Self
pub fn push_history(&mut self, text: &str) -> &mut Self
Append a HISTORY card.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.