1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Network functionality for HL7 v2 MLLP connections.
//!
//! This module provides:
//! - **MLLP Codec**: Encoding and decoding of MLLP frames using Tokio's codec framework
//! - **MLLP Client**: Async TCP client for sending HL7 messages and receiving ACKs
//! - **MLLP Server**: Async TCP server for receiving HL7 messages and sending ACKs
//!
//! # MLLP Protocol
//!
//! MLLP (Minimal Lower Layer Protocol) is a simple framing protocol used to transmit
//! HL7 messages over TCP. Each message is wrapped with:
//! - Start byte: `0x0B` (vertical tab)
//! - Message content (HL7 message)
//! - End bytes: `0x1C 0x0D` (file separator + carriage return)
//!
//! # Examples
//!
//! ## Client Example
//!
//! ```no_run
//! use hl7v2::transport::network::{MllpClient, MllpClientBuilder};
//! use hl7v2::{Message, Delims};
//! use std::time::Duration;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a client
//! let mut client = MllpClientBuilder::new()
//! .connect_timeout(Duration::from_secs(5))
//! .read_timeout(Duration::from_secs(30))
//! .build();
//!
//! // Connect to server
//! let addr: std::net::SocketAddr = "127.0.0.1:2575".parse()?;
//! client.connect(addr).await?;
//!
//! // Send a message (assumes you have a Message)
//! # let message = Message { delims: Delims::default(), segments: vec![], charsets: vec![] };
//! let ack = client.send_message(&message).await?;
//!
//! // Close connection
//! client.close().await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Server Example
//!
//! ```no_run
//! use hl7v2::transport::network::{MllpServer, MllpServerConfig, MessageHandler};
//! use hl7v2::{Message, Error};
//!
//! struct MyHandler;
//!
//! impl MessageHandler for MyHandler {
//! async fn handle_message(&self, message: Message) -> Result<Option<Message>, Error> {
//! // Process the message and optionally return an ACK
//! println!("Received message with {} segments", message.segments.len());
//! Ok(None) // Return Some(ack_message) to send an ACK
//! }
//! }
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let mut server = MllpServer::new(MllpServerConfig::default());
//! let addr: std::net::SocketAddr = "127.0.0.1:2575".parse()?;
//! server.bind(addr).await?;
//! server.run(MyHandler).await?;
//! # Ok(())
//! # }
//! ```
pub use ;
pub use MllpCodec;
pub use ;