pub enum Key {
Name(String),
Occurrence(String, usize),
}Expand description
Selects a record by keyword.
A bare name is strict: get/set/remove error with
FitsError::AmbiguousKeyword if the keyword is
duplicated. The (name, occurrence) form targets exactly one record (0-based).
§Examples
let mut h = Header::new();
h.append("GAIN", 100).unwrap();
h.append("GAIN", 200).unwrap();
assert!(h.get::<i64>("GAIN").is_err()); // ambiguous bare name
assert_eq!(h.get::<i64>(("GAIN", 1)).unwrap(), Some(200)); // explicit occurrenceVariants§
Name(String)
The sole occurrence of a keyword (strict).
Occurrence(String, usize)
The n-th (0-based) occurrence of a keyword.
Implementations§
Source§impl Key
impl Key
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
The keyword this key refers to.
§Examples
let bare: Key = "GAIN".into();
let occ: Key = ("GAIN", 1).into();
assert_eq!(bare.name(), "GAIN");
assert_eq!(occ.name(), "GAIN");Sourcepub fn occurrence(&self) -> Option<usize>
pub fn occurrence(&self) -> Option<usize>
The selected occurrence index, if any.
§Examples
let bare: Key = "GAIN".into();
let occ: Key = ("GAIN", 1).into();
assert_eq!(bare.occurrence(), None);
assert_eq!(occ.occurrence(), Some(1));Trait Implementations§
impl Eq for Key
impl StructuralPartialEq for Key
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnsafeUnpin for Key
impl UnwindSafe for Key
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
Mutably borrows from an owned value. Read more