Skip to content

Commit

Permalink
src: Move projec code to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Oct 4, 2024
1 parent 83f683d commit 4334383
Show file tree
Hide file tree
Showing 32 changed files with 23 additions and 20 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/drivers/fake.rs → src/lib/drivers/fake.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
6 changes: 4 additions & 2 deletions src/drivers/mod.rs → src/lib/drivers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/drivers/rest/mod.rs → src/lib/drivers/rest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -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::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::sync::Arc;

use anyhow::Result;
use mavlink_server::callbacks::{Callbacks, MessageCallback};
use tokio::{
net::TcpStream,
sync::{broadcast, RwLock},
};
use tracing::*;

use crate::{
callbacks::{Callbacks, MessageCallback},
drivers::{
tcp::{tcp_receive_task, tcp_send_task},
Driver, DriverInfo,
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/tcp/mod.rs → src/lib/drivers/tcp/mod.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -10,6 +9,7 @@ use tokio::{
use tracing::*;

use crate::{
callbacks::Callbacks,
protocol::{read_all_messages, Protocol},
stats::accumulated::driver::AccumulatedDriverStats,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::sync::Arc;

use anyhow::Result;
use mavlink_server::callbacks::{Callbacks, MessageCallback};
use tokio::{
net::{TcpListener, TcpStream},
sync::{broadcast, RwLock},
};
use tracing::*;

use crate::{
callbacks::{Callbacks, MessageCallback},
drivers::{
tcp::{tcp_receive_task, tcp_send_task},
Driver, DriverInfo,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::{path::PathBuf, sync::Arc};

use anyhow::Result;
use mavlink_server::callbacks::{Callbacks, MessageCallback};
use tokio::{
io::{AsyncWriteExt, BufWriter},
sync::{broadcast, RwLock},
};
use tracing::*;

use crate::{
callbacks::{Callbacks, MessageCallback},
drivers::{Driver, DriverInfo},
protocol::Protocol,
stats::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::sync::Arc;

use anyhow::Result;
use mavlink_server::callbacks::{Callbacks, MessageCallback};
use tokio::{
net::UdpSocket,
sync::{broadcast, RwLock},
};
use tracing::*;

use crate::{
callbacks::{Callbacks, MessageCallback},
drivers::{Driver, DriverInfo},
protocol::{read_all_messages, Protocol},
stats::{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::{collections::HashMap, sync::Arc};

use anyhow::Result;
use mavlink_server::callbacks::{Callbacks, MessageCallback};
use tokio::{
net::UdpSocket,
sync::{broadcast, RwLock},
};
use tracing::*;

use crate::{
callbacks::{Callbacks, MessageCallback},
drivers::{Driver, DriverInfo},
protocol::{read_all_messages, Protocol},
stats::{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions src/lib/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 2 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4334383

Please sign in to comment.