pub struct Values<'a> { /* private fields */ }Expand description
Reads a .ork element’s child values, collecting a warning for anything it cannot.
Borrowed rather than owned so that walking a tree costs nothing: make one per element.
Implementations§
Source§impl<'a> Values<'a>
impl<'a> Values<'a>
Sourcepub fn new(
element: &'a Element,
at: &'a str,
warnings: &'a mut Vec<Warning>,
) -> Self
pub fn new( element: &'a Element, at: &'a str, warnings: &'a mut Vec<Warning>, ) -> Self
Reads the children of element, reporting anything odd as happening at at.
Sourcepub fn element(&mut self, names: &[&str]) -> Option<&'a Element>
pub fn element(&mut self, names: &[&str]) -> Option<&'a Element>
The first child called one of names, newest name first.
When more than one is present they are checked against each other, on the text and on
the method/type attribute that says what the text is measured from: in the reference
corpus OpenRocket agrees with itself on both, every time. A disagreement is therefore worth
a warning, and the first name still wins. The name that lost says something the design
does not hold, so it is kept as written, in x-openrocket.
Sourcepub fn word(&mut self, names: &[&str]) -> Option<String>
pub fn word(&mut self, names: &[&str]) -> Option<String>
The text of the first child called one of names, trimmed. An empty tag gives "".
Sourcepub fn number(&mut self, names: &[&str]) -> Option<f64>
pub fn number(&mut self, names: &[&str]) -> Option<f64>
A number. A tag whose text is not a finite number is ignored, with a warning.
Sourcepub fn count(&mut self, names: &[&str]) -> Option<u32>
pub fn count(&mut self, names: &[&str]) -> Option<u32>
A count. A negative or fractional one is ignored, with a warning.
Sourcepub fn flag(&mut self, names: &[&str]) -> Option<bool>
pub fn flag(&mut self, names: &[&str]) -> Option<bool>
A true/false flag. Anything else is ignored, with a warning.
Sourcepub fn dimension(&mut self, names: &[&str]) -> Option<Dimension>
pub fn dimension(&mut self, names: &[&str]) -> Option<Dimension>
A dimension, which may be auto with or without the number OpenRocket last worked out.
Sourcepub fn warn_at(&mut self, kind: WarningKind, message: impl Into<String>)
pub fn warn_at(&mut self, kind: WarningKind, message: impl Into<String>)
Records a warning about the element being read, for a caller that decided something this reader could not.
Sourcepub fn overrides(&mut self) -> Overrides
pub fn overrides(&mut self) -> Overrides
The mass, center of gravity and drag a component’s own figures are replaced by, and whether each covers the components inside this one.
Until schema 1.9 a file said that last once, with overridesubcomponents, for all three
quantities. OpenRocket 24.12 reads that flag, in schema 1.4, 1.8 and 1.10 files alike, as
setting all three, and where a component writes it beside a per-quantity flag, the tag
written later wins, quantity by quantity: measured on probe designs
(M2.2e6, ADR-095), whose answers hpr_validate::openrocket holds hpr
to. This reads it the same way. A flag tag written twice on one component is read at its
first copy only, and warned of, since which copy OpenRocket takes is not measured. What the
design does not hold (a flag read at one copy of two, or the single older flag beside a
drag override, which the design says per quantity) is kept as written, the flags all
together, so that an export writes back what the file said, in its order.