hl7-mllp 0.0.1

Transport-agnostic MLLP (Minimal Lower Layer Protocol) framing for HL7 v2 messages
Documentation
  • Coverage
  • 100%
    18 out of 18 items documented1 out of 10 items with examples
  • Size
  • Source code size: 21.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.82 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 36s Average build duration of successful builds.
  • all releases: 42s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Zluidr/hl7-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • SHA888

hl7-mllp

Crates.io Docs.rs License

Transport-agnostic MLLP framing for HL7 v2 messages.

MLLP (Minimal Lower Layer Protocol) is the standard transport envelope for HL7 v2 messages over TCP/IP. This crate provides pure frame encoding and decoding — with no opinion on async runtimes, I/O libraries, or transports.


Design Philosophy

Most existing Rust MLLP crates are tightly coupled to tokio. This crate is not.

  • No tokio dependency — bring your own transport
  • No async-std dependency — works in sync, async, and no_std contexts
  • [MllpTransport] trait — implement for TCP, serial, UART, in-memory, or anything else
  • Pure framing logic — encode, decode, find frame boundaries

MLLP Frame Format

[VT 0x0B] [HL7 message bytes ...] [FS 0x1C] [CR 0x0D]

Usage

use hl7_mllp::{MllpFrame, MllpError};

// Encode a raw HL7 payload into an MLLP frame
let payload = b"MSH|^~\\&|SendApp|SendFac|...";
let framed = MllpFrame::encode(payload);

// Decode an MLLP frame back to the raw HL7 payload
let decoded = MllpFrame::decode(&framed)?;
assert_eq!(decoded, payload);

// Find frame boundaries in a streaming buffer
if let Some(frame_len) = MllpFrame::find_frame_end(&buffer) {
    let frame = &buffer[..frame_len];
    let payload = MllpFrame::decode(frame)?;
    // process payload...
}

Implementing a custom transport

use hl7_mllp::MllpTransport;

struct MyTcpTransport { /* ... */ }

impl MllpTransport for MyTcpTransport {
    type Error = std::io::Error;

    fn read_frame(&mut self) -> Result<Vec<u8>, Self::Error> {
        // accumulate bytes until MllpFrame::find_frame_end returns Some
        todo!()
    }

    fn write_frame(&mut self, frame: &[u8]) -> Result<(), Self::Error> {
        // write frame bytes to the stream
        todo!()
    }
}

Ecosystem

This crate is part of a family of transport-agnostic HL7 and FHIR crates:

Crate Purpose
hl7-mllp MLLP framing (this crate)
hl7-v2 HL7 v2 message parser
hl7-mindray Mindray device HL7 field mappings
fhir-r4 FHIR R4 resource types
satusehat Indonesian SATUSEHAT FHIR profile

Status

0.0.1 — initial placeholder. Active development in progress.
Maintained by PT Teknorakit Inovasi Indonesia as part of the ZluidrOS ecosystem.

License

Apache-2.0