4 releases (2 breaking)
0.3.1 | Dec 12, 2020 |
---|---|
0.3.0 | Dec 3, 2020 |
0.2.0 | Nov 16, 2020 |
0.1.0 | Nov 6, 2020 |
#1639 in Parser implementations
27 downloads per month
Used in weldr-bin
86KB
2K
SLoC
👨🏭 weldr, the link between your favorite building blocks and Rust 🧱
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
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.
Dependencies
~2MB
~38K SLoC