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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//! # takproto
//!
//! A Rust library for sending TAK (Team Awareness Kit) Protocol messages to TAK servers
//! with full mTLS support.
//!
//! ## Features
//!
//! - **TAK Protocol Version 1** - Protocol Buffer-based messaging
//! - **mTLS Support** - Client certificate authentication
//! - **Protocol Negotiation** - Automatic handshake with TAK servers
//! - **XML Mode** - Legacy Protocol Version 0 support
//! - **Async/Await** - Built on Tokio
//! - **Type-Safe** - Generated protobuf types
//!
//! ## Feature Flags
//!
//! - **`openssl-p12`** - Enable full PKCS#12 support using OpenSSL for legacy TAK server certificates
//!
//! Enable in your `Cargo.toml`:
//! ```toml
//! [dependencies]
//! takproto = { version = "0.2", features = ["openssl-p12"] }
//! ```
//!
//! Without this feature, the library uses a pure Rust P12 parser which may not support
//! legacy formats. If you encounter P12 parsing errors, either enable this feature or
//! extract the P12 to PEM files.
//!
//! ## Quick Start
//!
//! ```no_run
//! use std::time::{SystemTime, UNIX_EPOCH};
//! use takproto::{TakClient, TlsConfig, proto::CotEvent};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Configure mTLS
//! let tls_config = TlsConfig::new_with_client_cert(
//! "ca.pem",
//! "client.pem",
//! "client-key.pem"
//! )?;
//!
//! // Connect to TAK server
//! let mut client = TakClient::connect_tls(
//! "takserver.example.com:8089",
//! "takserver.example.com",
//! tls_config
//! ).await?;
//!
//! // Negotiate protocol (optional)
//! client.negotiate_protocol(1, 60).await?;
//!
//! // Get current time
//! let now_ms = SystemTime::now()
//! .duration_since(UNIX_EPOCH)?
//! .as_millis() as u64;
//!
//! // Create a position report
//! let event = CotEvent {
//! r#type: "a-f-G-U-C".to_string(),
//! uid: "RUST-TAK-1".to_string(),
//! send_time: now_ms,
//! start_time: now_ms,
//! stale_time: now_ms + 60_000,
//! how: "m-g".to_string(),
//! lat: 37.7749,
//! lon: -122.4194,
//! hae: 10.0,
//! ce: 9.9,
//! le: 9.9,
//! ..Default::default()
//! };
//!
//! // Send the event
//! client.send_cot_event(event).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Protocol Modes
//!
//! ### Protobuf Mode (for high-frequency updates)
//!
//! ```no_run
//! # use takproto::{TakClient, TlsConfig};
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # let tls_config = TlsConfig::new_with_client_cert("ca.pem", "c.pem", "k.pem")?;
//! # let mut client = TakClient::connect_tls("s:8089", "s", tls_config).await?;
//! // Negotiate protocol
//! client.negotiate_protocol(1, 60).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ### XML Mode (for maximum compatibility)
//!
//! ```no_run
//! # use takproto::{TakClient, proto::CotEvent};
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # let mut client = TakClient::connect("127.0.0.1:8087").await?;
//! # let event = CotEvent::default();
//! // No negotiation needed - send directly as XML
//! client.send_cot_event_xml(event).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Helper Functions
//!
//! ```rust
//! use takproto::helpers::{url_to_uid, remarks, color, colors};
//!
//! // Convert URL to clean UID
//! let uid = url_to_uid("https://status.example.com"); // "status.example.com"
//!
//! // Create colored marker details
//! let xml = format!("{}\n{}",
//! remarks("System Status"),
//! color(colors::GREEN)
//! );
//! ```
pub use TakClient;
pub use ;
pub use ;
pub use CotEventBuilder;