weldr

Crates.ioweldr
lib.rsweldr
version0.3.1
sourcesrc
created_at2020-11-06 17:53:14.906429
updated_at2020-12-12 16:59:40.850506
descriptionA Rust library to manage LDraw files (.ldr)
homepage
repositoryhttps://github.com/djeedai/weldr
max_upload_size
id309287
size91,982
Jerome Humbert (djeedai)

documentation

https://docs.rs/weldr

README

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

LICENSE 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.44, 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

The current code repository is licensed under the MIT license.

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.

Commit count: 84

cargo fmt