pub mod constants;
pub mod helper_functions;
pub mod message_builders;
pub mod message_primitives;
pub mod network_workers;
#[derive(Debug)]
pub enum RustakError {
Io(std::io::Error),
XmlParse(xmltree::ParseError),
Helper(helper_functions::HelperError),
TlsConfig(String),
ConnectionFailed(String),
SendError(String),
ChannelClosed,
Other(String),
}
impl std::fmt::Display for RustakError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RustakError::Io(e) => write!(f, "IO error: {}", e),
RustakError::XmlParse(e) => write!(f, "XML parse error: {}", e),
RustakError::Helper(e) => write!(f, "Helper function error: {}", e),
RustakError::TlsConfig(s) => write!(f, "TLS configuration error: {}", s),
RustakError::ConnectionFailed(s) => write!(f, "Connection failed: {}", s),
RustakError::SendError(s) => write!(f, "Send error: {}", s),
RustakError::ChannelClosed => write!(f, "Channel was closed unexpectedly"),
RustakError::Other(s) => write!(f, "RusTAK error: {}", s),
}
}
}
impl std::error::Error for RustakError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
RustakError::Io(e) => Some(e),
RustakError::XmlParse(e) => Some(e),
RustakError::Helper(e) => Some(e), _ => None,
}
}
}
impl From<std::io::Error> for RustakError {
fn from(err: std::io::Error) -> Self {
RustakError::Io(err)
}
}
impl From<xmltree::ParseError> for RustakError {
fn from(err: xmltree::ParseError) -> Self {
RustakError::XmlParse(err)
}
}
impl From<helper_functions::HelperError> for RustakError {
fn from(err: helper_functions::HelperError) -> Self {
RustakError::Helper(err)
}
}
pub use network_workers::{
tcp_receiver, tcp_sender, tls_receiver, tls_sender, udp_receiver, udp_sender,
};
pub use message_primitives::{
create_cot_colors,
create_cot_point,
create_cot_polygon_shape, create_cot_root_fields,
create_cot_track,
};
pub use message_builders::{create_cot_atom_message, create_cot_polygon_message};
pub use helper_functions::{cot_time, parse_url, split_host};
pub use constants::{DEFAULT_TCP_PORT, DEFAULT_TLS_PORT, DEFAULT_UDP_PORT};