Function udp_receiver

Source
pub async fn udp_receiver(
    listen_addr: SocketAddr,
    send_channel: Sender<Result<Element, RustakError>>,
) -> Result<(), RustakError>
Expand description

Asynchronously receives and parses CoT messages from a UDP socket.

Binds to the specified listen_addr. It reads UDP datagrams, attempts to parse each datagram as an XML CoT message, and sends the Result<xmltree::Element, RustakError> to the provided send_channel.

This function runs in an infinite loop. It will only terminate and return an Err if a fatal error occurs during socket binding, receiving data (RustakError::Io), or sending to the send_channel (RustakError::ChannelClosed).

§Arguments

  • listen_addr: The SocketAddr to bind the UDP socket to for listening.
  • send_channel: An MPSC sender channel to send parsed CoT elements or errors to.

§Returns

This function is designed to loop indefinitely. It returns Err(RustakError) if an unrecoverable error occurs. It does not return Ok(()) under normal operation.