mavlink_core/connection/
mod.rs1macro_rules! dispatch_transport {
2 ($inner:expr, |$transport:ident| $call:expr) => {
3 match $inner {
4 #[cfg(feature = "transport-tcp")]
5 Transport::Tcp($transport) => $call,
6 #[cfg(feature = "transport-udp")]
7 Transport::Udp($transport) => $call,
8 #[cfg(feature = "transport-direct-serial")]
9 Transport::Serial($transport) => $call,
10 Transport::File($transport) => $call,
11 }
12 };
13}
14
15mod sync;
16
17#[cfg(feature = "transport-tcp")]
18pub mod tcp;
19
20#[cfg(feature = "transport-udp")]
21pub mod udp;
22
23#[cfg(feature = "transport-direct-serial")]
24pub mod direct_serial;
25
26pub mod file;
27
28#[cfg(any(feature = "transport-tcp", feature = "transport-udp"))]
29use std::io;
30pub use sync::{
31 Connectable, Connection, DialectConnection, MavConnection, connect, connect_with_dialect,
32};
33
34#[cfg(any(feature = "transport-tcp", feature = "transport-udp"))]
36pub(crate) fn get_socket_addr<T: std::net::ToSocketAddrs>(
37 address: &T,
38) -> Result<std::net::SocketAddr, io::Error> {
39 address
40 .to_socket_addrs()?
41 .next()
42 .ok_or(io::Error::other("Host address lookup failed"))
43}
44
45#[cfg(feature = "tokio")]
46mod r#async;
47#[cfg(feature = "tokio")]
48pub use r#async::{
49 AsyncConnectable, AsyncConnection, AsyncDialectConnection, AsyncMavConnection, connect_async,
50 connect_async_with_dialect,
51};