Crates.io | weldr |
lib.rs | weldr |
version | 0.3.1 |
source | src |
created_at | 2020-11-06 17:53:14.906429 |
updated_at | 2020-12-12 16:59:40.850506 |
description | A Rust library to manage LDraw files (.ldr) |
homepage | |
repository | https://github.com/djeedai/weldr |
max_upload_size | |
id | 309287 |
size | 91,982 |
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.
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]);
}
weldr is tested with rustc
version 1.44, stable, and beta, although older versions may work, but have never been tested.
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;
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:
<CR><LF>
and Unix <LF>
line termination acceptedThe 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.