dxfbin 0.1.0

Streaming text DXF to binary DXF converter
Documentation
  • Coverage
  • 97.92%
    47 out of 48 items documented0 out of 27 items with examples
  • Size
  • Source code size: 34.01 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.02 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 18s Average build duration of successful builds.
  • all releases: 18s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • xorgy/dxfbin
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xorgy

dxfbin

Streaming text DXF to binary DXF converter.

Converts AutoCAD text-format DXF files to the binary DXF format without interpreting the drawing structure. Each group code/value pair is read, typed according to the DXF group code specification, and written in its binary encoding. The conversion is streaming and no_std-compatible.

Library usage

One-shot conversion from a byte slice:

use dxfbin::{BinarySink, convert_all};

let text_dxf = b"  0\nSECTION\n  2\nHEADER\n  0\nENDSEC\n  0\nEOF\n";
let mut out = Vec::new();
let mut sink = BinarySink::new(&mut out);
convert_all(text_dxf, &mut sink).unwrap();

Streaming conversion via std::io::Read:

use dxfbin::StreamConverter;
use std::io::{BufReader, Read};

let text_dxf = b"  0\nSECTION\n  2\nHEADER\n  0\nENDSEC\n  0\nEOF\n";
let mut converter = StreamConverter::new(BufReader::new(&text_dxf[..]));
let mut binary = Vec::new();
converter.read_to_end(&mut binary).unwrap();

Incremental feeding for custom buffering:

use dxfbin::{BinarySink, Converter};

let mut converter = Converter::new();
let mut out = Vec::new();
let mut sink = BinarySink::new(&mut out);
let chunk = b"  0\nEOF\n";
converter.feed(chunk, &mut sink).unwrap();

Typed sink

The [Sink] trait receives typed values (boolean, i16, i32, i64, f64, string, binary chunk) rather than raw bytes, so implementations can inspect or transform values by type.

no_std

[dependencies]
dxfbin = { version = "0.1", default-features = false }

The std feature (on by default) adds the StreamConverter adapter.

CLI

The crate includes a dxfbin binary that reads text DXF from stdin and writes binary DXF to stdout:

dxfbin < drawing.dxf > drawing.bin.dxf

License

ISC