Skip to main content

Values

Struct Values 

Source
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>

Source

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.

Source

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.

Source

pub fn word(&mut self, names: &[&str]) -> Option<String>

The text of the first child called one of names, trimmed. An empty tag gives "".

Source

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.

Source

pub fn count(&mut self, names: &[&str]) -> Option<u32>

A count. A negative or fractional one is ignored, with a warning.

Source

pub fn flag(&mut self, names: &[&str]) -> Option<bool>

A true/false flag. Anything else is ignored, with a warning.

Source

pub fn dimension(&mut self, names: &[&str]) -> Option<Dimension>

A dimension, which may be auto with or without the number OpenRocket last worked out.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a> Debug for Values<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for Values<'a>

§

impl<'a> Freeze for Values<'a>

§

impl<'a> RefUnwindSafe for Values<'a>

§

impl<'a> Send for Values<'a>

§

impl<'a> Sync for Values<'a>

§

impl<'a> Unpin for Values<'a>

§

impl<'a> UnsafeUnpin for Values<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.