Skip to main content

write

Function write 

Source
pub fn write(file: &EngFile) -> Result<String, MotorError>
Expand description

Writes a .eng file: a first comment naming the program that wrote it, its version and its designation (; hpr-sim 0.1.0 · FS · SW · TOOL 005, hpr_core::tool::stamp); then each entry’s comments, header and points, then a ; separator; and the trailing comments last. A comment carried over that names an earlier program the same way, as a file hpr wrote before holds, is left out, so converting a file again writes one such line, not two. The reader doesn’t keep that line (parse).

§Errors

  • MotorError::Inconsistent for a name that is empty, holds whitespace or starts with ;; delays that are empty or hold whitespace; a manufacturer that is empty or isn’t its words joined by single spaces; a comment that is empty, holds a line break or ends in whitespace; an entry with no points; or a file with no entries. The reader would not read these back unchanged.
  • MotorError::Domain for the values the reader rejects: non-finite numbers, a non-positive diameter or length, negative masses or times, and decreasing times.