diff --git a/src/cli.rs b/src/lib/cli.rs similarity index 100% rename from src/cli.rs rename to src/lib/cli.rs diff --git a/src/drivers/fake.rs b/src/lib/drivers/fake.rs similarity index 99% rename from src/drivers/fake.rs rename to src/lib/drivers/fake.rs index 9eb7f943..4ac0937a 100644 --- a/src/drivers/fake.rs +++ b/src/lib/drivers/fake.rs @@ -1,11 +1,11 @@ use std::sync::Arc; use anyhow::Result; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::sync::{broadcast, RwLock}; use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{Driver, DriverInfo}, protocol::{read_all_messages, Protocol}, stats::{ diff --git a/src/drivers/mod.rs b/src/lib/drivers/mod.rs similarity index 98% rename from src/drivers/mod.rs rename to src/lib/drivers/mod.rs index f07dd224..90b2681a 100644 --- a/src/drivers/mod.rs +++ b/src/lib/drivers/mod.rs @@ -231,11 +231,13 @@ mod tests { use anyhow::{anyhow, Result}; use mavlink::MAVLinkV2MessageRaw; - use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::sync::RwLock; use tracing::*; - use crate::stats::{accumulated::driver::AccumulatedDriverStats, driver::DriverUuid}; + use crate::{ + callbacks::{Callbacks, MessageCallback}, + stats::{accumulated::driver::AccumulatedDriverStats, driver::DriverUuid}, + }; use super::*; diff --git a/src/drivers/rest/data.rs b/src/lib/drivers/rest/data.rs similarity index 100% rename from src/drivers/rest/data.rs rename to src/lib/drivers/rest/data.rs diff --git a/src/drivers/rest/mod.rs b/src/lib/drivers/rest/mod.rs similarity index 99% rename from src/drivers/rest/mod.rs rename to src/lib/drivers/rest/mod.rs index d92095fb..69b94583 100644 --- a/src/drivers/rest/mod.rs +++ b/src/lib/drivers/rest/mod.rs @@ -3,12 +3,12 @@ pub mod data; use std::sync::Arc; use anyhow::Result; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use serde::{Deserialize, Serialize}; use tokio::sync::{broadcast, RwLock}; use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{Driver, DriverInfo}, protocol::Protocol, stats::{ diff --git a/src/drivers/serial/mod.rs b/src/lib/drivers/serial/mod.rs similarity index 99% rename from src/drivers/serial/mod.rs rename to src/lib/drivers/serial/mod.rs index d9239ba6..95293598 100644 --- a/src/drivers/serial/mod.rs +++ b/src/lib/drivers/serial/mod.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use anyhow::Result; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, sync::{broadcast, Mutex, RwLock}, @@ -10,6 +9,7 @@ use tokio_serial::{self, SerialPortBuilderExt}; use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{Driver, DriverInfo}, protocol::{read_all_messages, Protocol}, stats::{ diff --git a/src/drivers/tcp/client.rs b/src/lib/drivers/tcp/client.rs similarity index 98% rename from src/drivers/tcp/client.rs rename to src/lib/drivers/tcp/client.rs index 8d6bd545..706aaaef 100644 --- a/src/drivers/tcp/client.rs +++ b/src/lib/drivers/tcp/client.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use anyhow::Result; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::{ net::TcpStream, sync::{broadcast, RwLock}, @@ -9,6 +8,7 @@ use tokio::{ use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{ tcp::{tcp_receive_task, tcp_send_task}, Driver, DriverInfo, diff --git a/src/drivers/tcp/mod.rs b/src/lib/drivers/tcp/mod.rs similarity index 98% rename from src/drivers/tcp/mod.rs rename to src/lib/drivers/tcp/mod.rs index dfdf1d67..8f57c4bd 100644 --- a/src/drivers/tcp/mod.rs +++ b/src/lib/drivers/tcp/mod.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use anyhow::Result; -use mavlink_server::callbacks::Callbacks; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, net::tcp::{OwnedReadHalf, OwnedWriteHalf}, @@ -10,6 +9,7 @@ use tokio::{ use tracing::*; use crate::{ + callbacks::Callbacks, protocol::{read_all_messages, Protocol}, stats::accumulated::driver::AccumulatedDriverStats, }; diff --git a/src/drivers/tcp/server.rs b/src/lib/drivers/tcp/server.rs similarity index 99% rename from src/drivers/tcp/server.rs rename to src/lib/drivers/tcp/server.rs index 4b0f0f50..f7791f2b 100644 --- a/src/drivers/tcp/server.rs +++ b/src/lib/drivers/tcp/server.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use anyhow::Result; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::{ net::{TcpListener, TcpStream}, sync::{broadcast, RwLock}, @@ -9,6 +8,7 @@ use tokio::{ use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{ tcp::{tcp_receive_task, tcp_send_task}, Driver, DriverInfo, diff --git a/src/drivers/tlog/mod.rs b/src/lib/drivers/tlog/mod.rs similarity index 100% rename from src/drivers/tlog/mod.rs rename to src/lib/drivers/tlog/mod.rs diff --git a/src/drivers/tlog/reader.rs b/src/lib/drivers/tlog/reader.rs similarity index 99% rename from src/drivers/tlog/reader.rs rename to src/lib/drivers/tlog/reader.rs index a28d6789..e3c7a84c 100644 --- a/src/drivers/tlog/reader.rs +++ b/src/lib/drivers/tlog/reader.rs @@ -3,11 +3,11 @@ use std::{path::PathBuf, sync::Arc}; use anyhow::{Context, Result}; use chrono::DateTime; use mavlink::ardupilotmega::MavMessage; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::sync::{broadcast, RwLock}; use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{Driver, DriverInfo}, protocol::Protocol, stats::{ diff --git a/src/drivers/tlog/writer.rs b/src/lib/drivers/tlog/writer.rs similarity index 98% rename from src/drivers/tlog/writer.rs rename to src/lib/drivers/tlog/writer.rs index 12d2127b..3a61d30a 100644 --- a/src/drivers/tlog/writer.rs +++ b/src/lib/drivers/tlog/writer.rs @@ -1,7 +1,6 @@ use std::{path::PathBuf, sync::Arc}; use anyhow::Result; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::{ io::{AsyncWriteExt, BufWriter}, sync::{broadcast, RwLock}, @@ -9,6 +8,7 @@ use tokio::{ use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{Driver, DriverInfo}, protocol::Protocol, stats::{ diff --git a/src/drivers/udp/client.rs b/src/lib/drivers/udp/client.rs similarity index 99% rename from src/drivers/udp/client.rs rename to src/lib/drivers/udp/client.rs index 7cbb6a15..f3ddd008 100644 --- a/src/drivers/udp/client.rs +++ b/src/lib/drivers/udp/client.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use anyhow::Result; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::{ net::UdpSocket, sync::{broadcast, RwLock}, @@ -9,6 +8,7 @@ use tokio::{ use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{Driver, DriverInfo}, protocol::{read_all_messages, Protocol}, stats::{ diff --git a/src/drivers/udp/mod.rs b/src/lib/drivers/udp/mod.rs similarity index 100% rename from src/drivers/udp/mod.rs rename to src/lib/drivers/udp/mod.rs diff --git a/src/drivers/udp/server.rs b/src/lib/drivers/udp/server.rs similarity index 99% rename from src/drivers/udp/server.rs rename to src/lib/drivers/udp/server.rs index 798ffdca..649d3a1e 100644 --- a/src/drivers/udp/server.rs +++ b/src/lib/drivers/udp/server.rs @@ -1,7 +1,6 @@ use std::{collections::HashMap, sync::Arc}; use anyhow::Result; -use mavlink_server::callbacks::{Callbacks, MessageCallback}; use tokio::{ net::UdpSocket, sync::{broadcast, RwLock}, @@ -9,6 +8,7 @@ use tokio::{ use tracing::*; use crate::{ + callbacks::{Callbacks, MessageCallback}, drivers::{Driver, DriverInfo}, protocol::{read_all_messages, Protocol}, stats::{ diff --git a/src/hub/actor.rs b/src/lib/hub/actor.rs similarity index 100% rename from src/hub/actor.rs rename to src/lib/hub/actor.rs diff --git a/src/hub/mod.rs b/src/lib/hub/mod.rs similarity index 100% rename from src/hub/mod.rs rename to src/lib/hub/mod.rs diff --git a/src/hub/protocol.rs b/src/lib/hub/protocol.rs similarity index 100% rename from src/hub/protocol.rs rename to src/lib/hub/protocol.rs diff --git a/src/logger.rs b/src/lib/logger.rs similarity index 100% rename from src/logger.rs rename to src/lib/logger.rs diff --git a/src/lib/mod.rs b/src/lib/mod.rs index bd482ca3..69024b33 100644 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -1 +1,8 @@ pub mod callbacks; +pub mod cli; +pub mod drivers; +pub mod hub; +pub mod logger; +pub mod protocol; +pub mod stats; +pub mod web; diff --git a/src/protocol.rs b/src/lib/protocol.rs similarity index 100% rename from src/protocol.rs rename to src/lib/protocol.rs diff --git a/src/stats/accumulated/driver.rs b/src/lib/stats/accumulated/driver.rs similarity index 100% rename from src/stats/accumulated/driver.rs rename to src/lib/stats/accumulated/driver.rs diff --git a/src/stats/accumulated/messages.rs b/src/lib/stats/accumulated/messages.rs similarity index 100% rename from src/stats/accumulated/messages.rs rename to src/lib/stats/accumulated/messages.rs diff --git a/src/stats/accumulated/mod.rs b/src/lib/stats/accumulated/mod.rs similarity index 100% rename from src/stats/accumulated/mod.rs rename to src/lib/stats/accumulated/mod.rs diff --git a/src/stats/actor.rs b/src/lib/stats/actor.rs similarity index 100% rename from src/stats/actor.rs rename to src/lib/stats/actor.rs diff --git a/src/stats/driver.rs b/src/lib/stats/driver.rs similarity index 100% rename from src/stats/driver.rs rename to src/lib/stats/driver.rs diff --git a/src/stats/messages.rs b/src/lib/stats/messages.rs similarity index 100% rename from src/stats/messages.rs rename to src/lib/stats/messages.rs diff --git a/src/stats/mod.rs b/src/lib/stats/mod.rs similarity index 100% rename from src/stats/mod.rs rename to src/lib/stats/mod.rs diff --git a/src/stats/protocol.rs b/src/lib/stats/protocol.rs similarity index 100% rename from src/stats/protocol.rs rename to src/lib/stats/protocol.rs diff --git a/src/web/endpoints.rs b/src/lib/web/endpoints.rs similarity index 100% rename from src/web/endpoints.rs rename to src/lib/web/endpoints.rs diff --git a/src/web/mod.rs b/src/lib/web/mod.rs similarity index 100% rename from src/web/mod.rs rename to src/lib/web/mod.rs diff --git a/src/main.rs b/src/main.rs index 130e925f..cabec6b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,8 @@ -mod cli; -mod drivers; -mod hub; -mod logger; -mod protocol; -mod stats; -mod web; - use anyhow::*; use tracing::*; +use mavlink_server::{cli, hub, logger, web}; + #[tokio::main(flavor = "multi_thread", worker_threads = 10)] async fn main() -> Result<()> { // CLI should be started before logger to allow control over verbosity