[][src]Function weldr::parse_raw

pub fn parse_raw(ldr_content: &[u8]) -> Result<Vec<Command>, Error>

Parse raw LDR content without sub-file resolution.

Parse the given LDR data passed in ldr_content and return the list of parsed commands. Sub-file references (Line Type 1) are not resolved, and returned as SubFileRef::UnresolvedRef.

The input LDR content must comply to the LDraw standard. In particular this means:

  • UTF-8 encoded, without Byte Order Mark (BOM)
  • Both DOS/Windows and Unix line termination accepted
use weldr::{parse_raw, Command, CommentCmd, LineCmd, Vec3};

fn main() {
  let cmd0 = Command::Comment(CommentCmd::new("this is a comment"));
  let cmd1 = Command::Line(LineCmd{
    color: 16,
    vertices: [
      Vec3{ x: 0.0, y: 0.0, z: 0.0 },
      Vec3{ x: 1.0, y: 1.0, z: 1.0 }
    ]
  });
  assert_eq!(parse_raw(b"0 this is a comment\n2 16 0 0 0 1 1 1").unwrap(), vec![cmd0, cmd1]);
}