Skip to content

Commit

Permalink
doc: replace block with yield, move file comment, fmt cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
pv42 authored and patrickelectric committed Sep 9, 2024
1 parent 68536ef commit 38e85b6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions mavlink-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ embedded-io-async = { version = "0.6.1", optional = true }
serde = { version = "1.0.115", optional = true, features = ["derive"] }
serde_arrays = { version = "0.1.0", optional = true }
serial = { version = "0.4", optional = true }
tokio = { version = "1.0", default-features = false, features = ["io-util", "net", "sync", "fs", ], optional = true }
tokio = { version = "1.0", default-features = false, features = ["io-util", "net", "sync", "fs"], optional = true }
sha2 = { version = "0.10", optional = true }
async-trait = { version = "0.1.18", optional = true }

Expand All @@ -46,4 +46,4 @@ async-trait = { version = "0.1.18", optional = true }
default = ["std", "tcp", "udp", "direct-serial", "serde"]

[dev-dependencies]
tokio = { version = "1.0", default-features = false, features = ["io-util", "net", "sync", "fs","macros", "rt" ] }
tokio = { version = "1.0", default-features = false, features = ["io-util", "net", "sync", "fs", "macros", "rt"] }
4 changes: 2 additions & 2 deletions mavlink-core/src/async_connection/file.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Async File MAVLINK connection

use core::ops::DerefMut;

use super::AsyncMavConnection;
Expand All @@ -15,8 +17,6 @@ use crate::read_versioned_msg_async;
#[cfg(feature = "signing")]
use crate::{read_versioned_msg_async_signed, SigningConfig, SigningData};

/// File MAVLINK connection

pub async fn open(file_path: &str) -> io::Result<AsyncFileConnection> {
let file = File::open(file_path).await?;
Ok(AsyncFileConnection {
Expand Down
2 changes: 1 addition & 1 deletion mavlink-core/src/async_connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::SigningConfig;
pub trait AsyncMavConnection<M: Message + Sync + Send> {
/// Receive a mavlink message.
///
/// Wait until a valid frame is received, ignoring invalid messages.
/// Yield until a valid frame is received, ignoring invalid messages.
async fn recv(&self) -> Result<(MavHeader, M), crate::error::MessageReadError>;

/// Send a mavlink message
Expand Down
6 changes: 3 additions & 3 deletions mavlink-core/src/async_connection/tcp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Async TCP MAVLink connection

use super::{get_socket_addr, AsyncMavConnection};
use crate::async_peek_reader::AsyncPeekReader;
use crate::{MavHeader, MavlinkVersion, Message};
Expand All @@ -15,8 +17,6 @@ use crate::{
read_versioned_msg_async_signed, write_versioned_msg_async_signed, SigningConfig, SigningData,
};

/// TCP MAVLink connection

pub async fn select_protocol<M: Message + Sync + Send>(
address: &str,
) -> io::Result<Box<dyn AsyncMavConnection<M> + Sync + Send>> {
Expand Down Expand Up @@ -57,7 +57,7 @@ pub async fn tcpin<T: std::net::ToSocketAddrs>(address: T) -> io::Result<TcpConn
let addr = get_socket_addr(address)?;
let listener = TcpListener::bind(addr).await?;

//For now we only accept one incoming stream: this blocks until we get one
//For now we only accept one incoming stream: this yields until we get one
match listener.accept().await {
Ok((socket, _)) => {
let (reader, writer) = socket.into_split();
Expand Down
2 changes: 2 additions & 0 deletions mavlink-core/src/async_connection/udp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Async UDP MAVLink connection

use core::{ops::DerefMut, task::Poll};
use std::{collections::VecDeque, io::Read, sync::Arc};

Expand Down
1 change: 0 additions & 1 deletion mavlink-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@ fn read_v2_raw_message_inner<M: Message, R: Read>(
}

/// Async read a raw buffer with the mavlink message
///
/// V2 maximum size is 280 bytes: `<https://mavlink.io/en/guide/serialization.html>`
#[cfg(feature = "tokio-1")]
pub async fn read_v2_raw_message_async<M: Message, R: tokio::io::AsyncReadExt + Unpin>(
Expand Down

0 comments on commit 38e85b6

Please sign in to comment.