pub struct Record {
pub kind: RecordKind,
/* private fields */
}Expand description
One header card. Carries its parsed RecordKind plus, when parsed and unmodified, the
original bytes of its physical card(s) so it can be serialized verbatim.
§Examples
let r = Record::value("OBJECT", Value::Str("M31".to_string()), Some("target".to_string()));
assert_eq!(r.keyword(), Some("OBJECT"));
assert_eq!(r.str_content(), Some("M31"));
assert_eq!(r.comment(), Some("target"));Fields§
§kind: RecordKindThe semantic content.
Implementations§
Source§impl Record
impl Record
Sourcepub fn value(
keyword: impl Into<String>,
value: Value,
comment: Option<String>,
) -> Self
pub fn value( keyword: impl Into<String>, value: Value, comment: Option<String>, ) -> Self
A new value card (not byte-backed; formatted on write).
§Examples
let r = Record::value("EXPTIME", Value::Literal("120.0".to_string()), None);
assert_eq!(r.keyword(), Some("EXPTIME"));
assert_eq!(r.value_text(), Some("120.0"));Sourcepub fn commentary(keyword: impl Into<String>, text: impl Into<String>) -> Self
pub fn commentary(keyword: impl Into<String>, text: impl Into<String>) -> Self
A new commentary card (not byte-backed; formatted on write).
§Examples
let r = Record::commentary("HISTORY", "dark subtracted");
assert_eq!(r.keyword(), Some("HISTORY"));
assert_eq!(r.value_text(), Some("dark subtracted"));Sourcepub fn keyword(&self) -> Option<&str>
pub fn keyword(&self) -> Option<&str>
The addressable keyword, or None for opaque cards.
§Examples
let mut h = Header::new();
h.set("OBJECT", "M31").unwrap();
assert_eq!(h.cards()[0].keyword(), Some("OBJECT"));Sourcepub fn value_text(&self) -> Option<&str>
pub fn value_text(&self) -> Option<&str>
The value as text for typed reads: Str content (non-empty), a Literal token, or
commentary text. None for empty strings and opaque cards.
§Examples
let mut h = Header::new();
h.set("EXPTIME", 120.0).unwrap();
assert_eq!(h.cards()[0].value_text(), Some("120.0"));Sourcepub fn str_content(&self) -> Option<&str>
pub fn str_content(&self) -> Option<&str>
The Str content of a value card (non-empty), for Header::get_str.
§Examples
let mut h = Header::new();
h.set("OBJECT", "M31").unwrap();
h.set("EXPTIME", 120.0).unwrap(); // a Literal, not Str content
assert_eq!(h.cards()[0].str_content(), Some("M31"));
assert_eq!(h.cards()[1].str_content(), None);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Record
impl<'de> Deserialize<'de> for Record
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnsafeUnpin for Record
impl UnwindSafe for Record
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