Skip to content

Latest commit

 

History

History

lib

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

👨‍🏭 weldr, the link between your favorite building blocks and Rust 🧱

License: MIT or Apache 2.0 Crates.io Version CI Coverage Status Minimum rustc version

weldr is a Rust library and command-line tool to manipulate LDraw files (format specification), which are files describing 3D models of LEGO®* pieces.

The 📦 weldr crate contains the library which allows building command-line tools and applications leveraging the fantastic database of pieces contributed by the LDraw community.

Note: For the binary command-line tool ⚙ weldr, see the 📦 weldr-bin crate instead.

Example

Use the weldr crate to parse the content of a single LDraw file containing 2 commands:

extern crate weldr;

use weldr::{parse_raw, Command, CommentCmd, LineCmd, Vec3};

fn main() {}

#[test]
fn parse_ldr() {
  let ldr = b"0 this is a comment\n2 16 0 0 0 1 1 1";
  let cmds = parse_raw(ldr);
  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!(cmds, vec![cmd0, cmd1]);
}

Documentation

Reference documentation

Rust version requirements

weldr is tested with rustc version 1.56, stable, and beta, although older versions may work, but have never been tested.

Installation

weldr is available on crates.io and can be included in your Cargo enabled project like this:

[dependencies]
weldr = "0.3"

Then include it in your code like this:

extern crate weldr;

Technical features

weldr leverages the nom parser combinator library to efficiently and reliably parse LDraw files, and transform them into in-memory data structures for consumption. All parsing is done on &[u8] input expected to contain specification-compliant LDraw content. In particular, this means:

  • UTF-8 encoded input
  • Both DOS/Windows <CR><LF> and Unix <LF> line termination accepted

Copyrights

LDraw™ is a trademark owned and licensed by the Estate of James Jessiman, which does not sponsor, endorse, or authorize this project.

*LEGO® is a registered trademark of the LEGO Group, which does not sponsor, endorse, or authorize this project.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.