From 41007284c8ef8224d00fb354a615f8d9db8f63b9 Mon Sep 17 00:00:00 2001 From: pv42 Date: Wed, 25 Mar 2026 14:21:24 +0100 Subject: [PATCH 1/2] doc: merge code blocks (doc_link_code lint) --- Cargo.toml | 1 + mavlink-core/src/lib.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b64569002ea..9adeb7e140b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,3 +22,4 @@ semicolon_if_nothing_returned = "warn" unnecessary_semicolon = "warn" uninlined_format_args = "warn" use_self = "warn" +doc_link_code = "warn" diff --git a/mavlink-core/src/lib.rs b/mavlink-core/src/lib.rs index 33ee854cad4..a1e3e203a53 100644 --- a/mavlink-core/src/lib.rs +++ b/mavlink-core/src/lib.rs @@ -45,7 +45,7 @@ //! When an invalidly signed message is received it is ignored. //! //! ## Read Errors -//! All `read_` functions return `Result<_,` [`MessageReadError`]`>`. +//! All `read_` functions return Result<_, [MessageReadError]>. //! //! - All functions will return [`MessageReadError::Io`] of [`UnexpectedEof`] when EOF is encountered before a message could be read. //! - All functions will return [`MessageReadError::Io`] when an error occurs on the underlying [`Read`]er or [`AsyncRead`]er. @@ -67,7 +67,7 @@ //! //! ## Write errors //! -//! All `write_` functions return `Result<_,` [`MessageWriteError`]`>`. +//! All `write_` functions return Result<_, [MessageWriteError]>. //! //! - When an error occurs on the underlying [`Write`]er or [`AsyncWrite`]er other then //! [`Interrupted`] the function returns [`MessageWriteError::Io`] @@ -512,7 +512,7 @@ pub async fn read_versioned_raw_message_async[ReadVersion::Single]([MavlinkVersion::V1]) signing is ignored. /// When using [`ReadVersion::Any`] MAVlink 1 messages are treated as unsigned. /// /// # Errors @@ -537,7 +537,7 @@ pub fn read_versioned_raw_message_signed( /// Read and parse a MAVLink message of the specified version from a [`PeekReader`] with signing support. /// -/// When using [`ReadVersion::Single`]`(`[`MavlinkVersion::V1`]`)` signing is ignored. +/// When using [ReadVersion::Single]([MavlinkVersion::V1]) signing is ignored. /// When using [`ReadVersion::Any`] MAVlink 1 messages are treated as unsigned. /// /// # Errors @@ -558,7 +558,7 @@ pub fn read_versioned_msg_signed( /// Asynchronously read and parse a MAVLinkMessageRaw of the specified version from a [`AsyncPeekReader`] with signing support. /// -/// When using [`ReadVersion::Single`]`(`[`MavlinkVersion::V1`]`)` signing is ignored. +/// When using [ReadVersion::Single]([MavlinkVersion::V1]) signing is ignored. /// When using [`ReadVersion::Any`] MAVlink 1 messages are treated as unsigned. /// /// # Errors @@ -586,7 +586,7 @@ pub async fn read_versioned_raw_message_async_signed< /// Asynchronously read and parse a MAVLink message of the specified version from a [`AsyncPeekReader`] with signing support. /// -/// When using [`ReadVersion::Single`]`(`[`MavlinkVersion::V1`]`)` signing is ignored. +/// When using [ReadVersion::Single]([MavlinkVersion::V1]) signing is ignored. /// When using [`ReadVersion::Any`] MAVlink 1 messages are treated as unsigned. /// /// # Errors From 0fb0312a37f3f005b7f939ddcee1d7770e8c8372 Mon Sep 17 00:00:00 2001 From: pv42 Date: Wed, 25 Mar 2026 17:30:59 +0100 Subject: [PATCH 2/2] add doc punctuation --- mavlink-bindgen/src/parser.rs | 59 ++++---- mavlink-core/src/async_peek_reader.rs | 26 ++-- mavlink-core/src/bytes.rs | 26 ++-- mavlink-core/src/bytes_mut.rs | 24 +-- mavlink-core/src/connection/mod.rs | 10 +- mavlink-core/src/connection/tcp/config.rs | 4 +- mavlink-core/src/connection/udp/config.rs | 2 +- mavlink-core/src/error.rs | 18 +-- mavlink-core/src/lib.rs | 171 +++++++++++----------- mavlink-core/src/peek_reader.rs | 26 ++-- mavlink-core/src/signing.rs | 2 +- mavlink-core/src/utils.rs | 2 +- 12 files changed, 187 insertions(+), 183 deletions(-) diff --git a/mavlink-bindgen/src/parser.rs b/mavlink-bindgen/src/parser.rs index 10bc4d6c1bd..663071b63fd 100644 --- a/mavlink-bindgen/src/parser.rs +++ b/mavlink-bindgen/src/parser.rs @@ -69,7 +69,7 @@ impl MavProfile { } /// Go over all fields in the messages, and if you encounter an enum, - /// which is a bitmask, set the bitmask size based on field size + /// which is a bitmask, set the bitmask size based on field size. fn update_enums(mut self) -> Self { for msg in self.messages.values_mut() { for field in &mut msg.fields { @@ -118,7 +118,7 @@ impl MavProfile { // self // } - /// Simple header comment + /// Emit simple header comment. #[inline(always)] fn emit_comments(&self, dialect_name: &str) -> TokenStream { let message = format!("MAVLink {dialect_name} dialect."); @@ -129,7 +129,7 @@ impl MavProfile { ) } - /// Emit rust messages + /// Emit rust messages. #[inline(always)] fn emit_msgs(&self) -> Vec { self.messages @@ -138,7 +138,7 @@ impl MavProfile { .collect() } - /// Emit rust enums + /// Emit rust enums. #[inline(always)] fn emit_enums(&self) -> Vec { self.enums.values().map(|d| d.emit_rust()).collect() @@ -157,7 +157,7 @@ impl MavProfile { .collect() } - /// Get list of original message names + /// Returns vector of original message names. #[inline(always)] fn emit_enum_names(&self) -> Vec { self.messages @@ -169,7 +169,7 @@ impl MavProfile { .collect() } - /// Emit message names with "_DATA" at the end + /// Emit message names with `_DATA` at the end. #[inline(always)] fn emit_struct_names(&self) -> Vec { self.messages @@ -845,8 +845,7 @@ pub struct MavMessage { } impl MavMessage { - /// Return Token of "MESSAGE_NAME_DATA - /// for mavlink struct data + /// Returns token of `MESSAGE_NAME_DATA` for mavlink struct data. fn emit_struct_name(&self) -> TokenStream { let name = format_ident!("{}", format!("{}_DATA", self.name)); quote!(#name) @@ -901,7 +900,7 @@ impl MavMessage { (field_toks, encoded_payload_len) } - /// Generate description for the given message + /// Generate description for the given message. #[inline(always)] fn emit_description(&self) -> TokenStream { let mut ts = TokenStream::new(); @@ -1101,7 +1100,7 @@ impl MavMessage { } } - /// Ensure that the fields count is at least one and no more than 64 + /// Ensures that the fields count is at least one and no more than 64. fn validate_field_count(&self) { assert!( !self.fields.is_empty(), @@ -1128,14 +1127,14 @@ pub struct MavField { } impl MavField { - /// Emit rust name of a given field + /// Emit rust name of the field. #[inline(always)] fn emit_name(&self) -> TokenStream { let name = format_ident!("{}", self.name); quote!(#name) } - /// Emit rust type of the field + /// Emit rust type of the field. #[inline(always)] fn emit_type(&self) -> TokenStream { let mavtype; @@ -1152,7 +1151,7 @@ impl MavField { mavtype } - /// Generate description for the given field + /// Generate description for the field. #[inline(always)] fn emit_description(&self) -> TokenStream { let mut ts = TokenStream::new(); @@ -1163,7 +1162,7 @@ impl MavField { ts } - /// Combine rust name and type of a given field + /// Emit rust name and type of the field. #[inline(always)] fn emit_name_type(&self) -> TokenStream { let name = self.emit_name(); @@ -1171,7 +1170,7 @@ impl MavField { quote!(pub #name: #fieldtype,) } - /// Emit writer + /// Emit writer for the field. fn rust_writer(&self) -> TokenStream { let mut name = "self.".to_string() + &self.name.clone(); if self.enumtype.is_some() { @@ -1200,7 +1199,7 @@ impl MavField { self.mavtype.rust_writer(&name, buf) } - /// Emit reader + /// Emit reader for the field. fn rust_reader(&self) -> TokenStream { let _name = TokenStream::from_str(&self.name).unwrap(); @@ -1309,7 +1308,7 @@ impl MavType { } } - /// Emit reader of a given type + /// Emit reader of the type. pub fn rust_reader(&self, val: &TokenStream, buf: Ident) -> TokenStream { use self::MavType::*; match self { @@ -1346,7 +1345,7 @@ impl MavType { } } - /// Emit writer of a given type + /// Emit writer of the type. pub fn rust_writer(&self, val: &TokenStream, buf: Ident) -> TokenStream { use self::MavType::*; match self { @@ -1381,7 +1380,7 @@ impl MavType { } } - /// Size of a given Mavtype + /// Returns size of a the type in bytes. fn len(&self) -> usize { use self::MavType::*; match self { @@ -1411,7 +1410,7 @@ impl MavType { } } - /// Used for ordering of types + /// Returns length value used for ordering of types. fn order_len(&self) -> usize { use self::MavType::*; match self { @@ -1423,7 +1422,9 @@ impl MavType { } } - /// Used for crc calculation + /// Returns C style name of the primitive type of the Mavtype. + /// + /// Used for crc calculation. pub fn primitive_type(&self) -> String { use self::MavType::*; match self { @@ -1444,7 +1445,8 @@ impl MavType { } } - /// Return rust equivalent of a given Mavtype + /// Returns rust equivalent of the Mavtype. + /// /// Used for generating struct fields. pub fn rust_type(&self) -> String { use self::MavType::*; @@ -1505,7 +1507,7 @@ impl MavType { } } - /// Compare two MavTypes + /// Compare two MavTypes for message field ordering. pub fn compare(&self, other: &Self) -> Ordering { let len = self.order_len(); (-(len as isize)).cmp(&(-(other.order_len() as isize))) @@ -2093,8 +2095,7 @@ pub fn parse_profile( Ok(profile.update_enums()) } -/// Generate protobuf represenation of mavlink message set -/// Generate rust representation of mavlink message set with appropriate conversion methods +/// Generate rust representation of mavlink message set. pub fn generate( definitions_dir: &Path, definition_file: &Path, @@ -2112,11 +2113,13 @@ pub fn generate( Ok(()) } +/// Calculates a message's [CRC_EXTRA byte](https://mavlink.io/en/guide/serialization.html#crc_extra). +/// /// CRC operates over names of the message and names of its fields /// Hence we have to preserve the original uppercase names delimited with an underscore /// For field names, we replace "type" with "mavtype" to make it rust compatible (this is /// needed for generating sensible rust code), but for calculating crc function we have to -/// use the original name "type" +/// use the original name "type". pub fn extra_crc(msg: &MavMessage) -> u8 { // calculate a 8-bit checksum of the key fields of a message, so we // can detect incompatible XML changes @@ -2192,7 +2195,7 @@ impl MavXmlFilter { true } - /// Ignore extension fields + /// Ignore extension fields. #[cfg(not(feature = "mav2-message-extensions"))] pub fn filter_extension(&mut self, element: &Result) -> bool { match element { @@ -2229,7 +2232,7 @@ impl MavXmlFilter { } } - /// Filters messages by their name + /// Filters messages by their name. pub fn filter_messages(&mut self, element: &Result) -> bool { match element { Ok(content) => { diff --git a/mavlink-core/src/async_peek_reader.rs b/mavlink-core/src/async_peek_reader.rs index b1f3e828943..93684d14493 100644 --- a/mavlink-core/src/async_peek_reader.rs +++ b/mavlink-core/src/async_peek_reader.rs @@ -28,7 +28,7 @@ use crate::error::MessageReadError; /// to `read` bytes (consuming them), or to `consume` them after `peek`ing. /// /// NOTE: This reader is generic over the size of the buffer, defaulting to MAVLink's current largest -/// possible message size of 280 bytes +/// possible message size of 280 bytes. /// pub struct AsyncPeekReader { // Internal buffer @@ -42,7 +42,7 @@ pub struct AsyncPeekReader { } impl AsyncPeekReader { - /// Instantiates a new [`AsyncPeekReader`], wrapping the provided [`tokio::io::AsyncReadExt`] and using the default chunk size + /// Instantiates a new [`AsyncPeekReader`], wrapping the provided [`tokio::io::AsyncReadExt`] and using the default chunk size. pub fn new(reader: R) -> Self { Self { buffer: [0; BUFFER_SIZE], @@ -52,7 +52,7 @@ impl AsyncPeekReader AsyncPeekReader Result<&[u8], MessageReadError> { self.fetch(amount, false).await } - /// Reads a specified amount of bytes from the internal buffer + /// Reads a specified amount of bytes from the internal buffer. /// /// If the internal buffer does not contain enough data, this function will read /// from the underlying [`tokio::io::AsyncReadExt`] until it does, an error occurs or no more data can be read (EOF). @@ -86,12 +86,12 @@ impl AsyncPeekReader Result<&[u8], MessageReadError> { self.fetch(amount, true).await } - /// Reads a byte from the internal buffer + /// Reads a byte from the internal buffer. /// /// If the internal buffer does not contain enough data, this function will read /// from the underlying [`tokio::io::AsyncReadExt`] until it does, an error occurs or no more data can be read (EOF). @@ -111,7 +111,7 @@ impl AsyncPeekReader AsyncPeekReader &R { &self.reader } - /// Returns a mutable reference to the underlying [`tokio::io::AsyncRead`] + /// Returns a mutable reference to the underlying [`tokio::io::AsyncRead`]. /// - /// Reading directly from the underlying reader will cause data loss + /// Reading directly from the underlying reader will cause data loss. pub fn reader_mut(&mut self) -> &mut R { &mut self.reader } - /// Internal function to fetch data from the internal buffer and/or reader + /// Internal function that fetches data from the internal buffer and/or reader. async fn fetch(&mut self, amount: usize, consume: bool) -> Result<&[u8], MessageReadError> { assert!(BUFFER_SIZE >= amount); diff --git a/mavlink-core/src/bytes.rs b/mavlink-core/src/bytes.rs index 06ed65b7c48..2e55dc86133 100644 --- a/mavlink-core/src/bytes.rs +++ b/mavlink-core/src/bytes.rs @@ -51,7 +51,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if not at least `count` bytes remain in the buffer + /// Will return an error if not at least `count` bytes remain in the buffer. #[inline] pub fn get_bytes(&mut self, count: usize) -> Result<&[u8], Error> { let bytes = &self @@ -64,7 +64,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if not at least `SIZE` bytes remain in the buffer + /// Will return an error if not at least `SIZE` bytes remain in the buffer. #[inline] pub fn get_array(&mut self) -> Result<[u8; SIZE], Error> { let bytes = self.get_bytes(SIZE)?; @@ -79,7 +79,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if nothing is remaining in the buffer + /// Will return an error if nothing is remaining in the buffer. #[inline] pub fn get_u8(&mut self) -> Result { let val = *self @@ -92,7 +92,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if nothing is remaining in the buffer + /// Will return an error if nothing is remaining in the buffer. #[inline] pub fn get_i8(&mut self) -> Result { let val = *self @@ -105,7 +105,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if less then the 2 required bytes for a `u16` remain + /// Will return an error if less then the 2 required bytes for a `u16` remain. #[inline] pub fn get_u16_le(&mut self) -> Result { Ok(u16::from_le_bytes(self.get_array()?)) @@ -113,7 +113,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if less then the 2 required bytes for a `i16` remain + /// Will return an error if less then the 2 required bytes for a `i16` remain. #[inline] pub fn get_i16_le(&mut self) -> Result { Ok(i16::from_le_bytes(self.get_array()?)) @@ -121,7 +121,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if not at least 3 bytes remain + /// Will return an error if not at least 3 bytes remain. #[inline] pub fn get_u24_le(&mut self) -> Result { const SIZE: usize = 3; @@ -140,7 +140,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if less then the 4 required bytes for a `u32` remain + /// Will return an error if less then the 4 required bytes for a `u32` remain. #[inline] pub fn get_u32_le(&mut self) -> Result { Ok(u32::from_le_bytes(self.get_array()?)) @@ -148,7 +148,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if less then the 4 required bytes for a `i32` remain + /// Will return an error if less then the 4 required bytes for a `i32` remain. #[inline] pub fn get_i32_le(&mut self) -> Result { Ok(i32::from_le_bytes(self.get_array()?)) @@ -156,7 +156,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if less then the 8 required bytes for a `u64` remain + /// Will return an error if less then the 8 required bytes for a `u64` remain. #[inline] pub fn get_u64_le(&mut self) -> Result { Ok(u64::from_le_bytes(self.get_array()?)) @@ -164,7 +164,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if less then the 8 required bytes for a `i64` remain + /// Will return an error if less then the 8 required bytes for a `i64` remain. #[inline] pub fn get_i64_le(&mut self) -> Result { Ok(i64::from_le_bytes(self.get_array()?)) @@ -172,7 +172,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if less then the 4 required bytes for a `f32` remain + /// Will return an error if less then the 4 required bytes for a `f32` remain. #[inline] pub fn get_f32_le(&mut self) -> Result { Ok(f32::from_le_bytes(self.get_array()?)) @@ -180,7 +180,7 @@ impl<'a> Bytes<'a> { /// # Errors /// - /// Will return an error if less then the 8 required bytes for a `f64` remain + /// Will return an error if less then the 8 required bytes for a `f64` remain. #[inline] pub fn get_f64_le(&mut self) -> Result { Ok(f64::from_le_bytes(self.get_array()?)) diff --git a/mavlink-core/src/bytes_mut.rs b/mavlink-core/src/bytes_mut.rs index c5b83dc4f96..180f39a81cb 100644 --- a/mavlink-core/src/bytes_mut.rs +++ b/mavlink-core/src/bytes_mut.rs @@ -34,7 +34,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if not enough space is remaining in the buffer to store the whole slice + /// Will panic if not enough space is remaining in the buffer to store the whole slice. #[inline] pub fn put_slice(&mut self, src: &[u8]) { self.check_remaining(src.len()); @@ -47,7 +47,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if no space is remaing in the buffer + /// Will panic if no space is remaing in the buffer. #[inline] pub fn put_u8(&mut self, val: u8) { self.check_remaining(1); @@ -58,7 +58,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if no space is remaing in the buffer + /// Will panic if no space is remaing in the buffer. #[inline] pub fn put_i8(&mut self, val: i8) { self.check_remaining(1); @@ -69,7 +69,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if less space then the 2 bytes required by a `u16` remain in the buffer + /// Will panic if less space then the 2 bytes required by a `u16` remain in the buffer. #[inline] pub fn put_u16_le(&mut self, val: u16) { const SIZE: usize = core::mem::size_of::(); @@ -82,7 +82,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if less space then the 2 bytes required by a `i16` remain in the buffer + /// Will panic if less space then the 2 bytes required by a `i16` remain in the buffer. #[inline] pub fn put_i16_le(&mut self, val: i16) { const SIZE: usize = core::mem::size_of::(); @@ -96,7 +96,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// /// Will panic if `val` is not a valid 24 bit unsigned integer or if not - /// enough space is remaing in the buffer to store 3 bytes + /// enough space is remaing in the buffer to store 3 bytes. #[inline] pub fn put_u24_le(&mut self, val: u32) { const SIZE: usize = 3; @@ -115,7 +115,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if less space then the 4 bytes required by a `u32` remain in the buffer + /// Will panic if less space then the 4 bytes required by a `u32` remain in the buffer. #[inline] pub fn put_u32_le(&mut self, val: u32) { const SIZE: usize = core::mem::size_of::(); @@ -128,7 +128,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if less space then the 4 bytes required by a `i32` remain in the buffer + /// Will panic if less space then the 4 bytes required by a `i32` remain in the buffer. #[inline] pub fn put_i32_le(&mut self, val: i32) { const SIZE: usize = core::mem::size_of::(); @@ -141,7 +141,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if less space then the 8 bytes required by a `u64` remain in the buffer + /// Will panic if less space then the 8 bytes required by a `u64` remain in the buffer. #[inline] pub fn put_u64_le(&mut self, val: u64) { const SIZE: usize = core::mem::size_of::(); @@ -154,7 +154,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if less space then the 8 bytes required by a `i64` remain in the buffer + /// Will panic if less space then the 8 bytes required by a `i64` remain in the buffer. #[inline] pub fn put_i64_le(&mut self, val: i64) { const SIZE: usize = core::mem::size_of::(); @@ -167,7 +167,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if less space then the 4 bytes required by a `f32` remain in the buffer + /// Will panic if less space then the 4 bytes required by a `f32` remain in the buffer. #[inline] pub fn put_f32_le(&mut self, val: f32) { const SIZE: usize = core::mem::size_of::(); @@ -180,7 +180,7 @@ impl<'a> BytesMut<'a> { /// # Panics /// - /// Will panic if less space then the 8 bytes required by a `f64` remain in the buffer + /// Will panic if less space then the 8 bytes required by a `f64` remain in the buffer. #[inline] pub fn put_f64_le(&mut self, val: f64) { const SIZE: usize = core::mem::size_of::(); diff --git a/mavlink-core/src/connection/mod.rs b/mavlink-core/src/connection/mod.rs index 6a69b62fde7..20aed124741 100644 --- a/mavlink-core/src/connection/mod.rs +++ b/mavlink-core/src/connection/mod.rs @@ -74,7 +74,7 @@ pub trait MavConnection { /// Sets the MAVLink version to use for receiving (when `allow_recv_any_version()` is `false`) and sending messages. fn set_protocol_version(&mut self, version: MavlinkVersion); - /// Gets the currently used MAVLink version + /// Gets the currently used MAVLink version. fn protocol_version(&self) -> MavlinkVersion; /// Set wether MAVLink messages of either version may be received. @@ -119,7 +119,7 @@ pub trait MavConnection { self.send(&header, data) } - /// Setup secret key used for message signing, or disable message signing + /// Setup the secret key used for message signing, or disable message signing. #[cfg(feature = "mav2-message-signing")] fn setup_signing(&mut self, signing_data: Option); } @@ -372,14 +372,14 @@ pub(crate) fn get_socket_addr( .ok_or(io::Error::other("Host address lookup failed")) } -/// A MAVLink connection address that can be connected to, establishing a [`MavConnection`] +/// A MAVLink connection address that can be connected to, establishing a [`MavConnection`]. pub trait Connectable: Display { - /// Attempt to establish a blocking MAVLink connection + /// Attempt to establish a blocking MAVLink connection. /// /// # Errors /// /// When the connection could not be established a corresponding - /// [`io::Error`] is returned + /// [`io::Error`] is returned. fn connect(&self) -> io::Result>; } diff --git a/mavlink-core/src/connection/tcp/config.rs b/mavlink-core/src/connection/tcp/config.rs index 35f95613e31..4983601bfe4 100644 --- a/mavlink-core/src/connection/tcp/config.rs +++ b/mavlink-core/src/connection/tcp/config.rs @@ -3,9 +3,9 @@ use core::fmt::Display; /// Type of TCP connection #[derive(Debug, Clone, Copy)] pub enum TcpMode { - /// Connection will open a TCP server that binds to the provided address + /// Connection will open a TCP server that binds to the provided address. TcpIn, - /// Connection will connect to the provided TCP server address + /// Connection will connect to the provided TCP server address. TcpOut, } diff --git a/mavlink-core/src/connection/udp/config.rs b/mavlink-core/src/connection/udp/config.rs index 516ca0b62ab..bca8cf765af 100644 --- a/mavlink-core/src/connection/udp/config.rs +++ b/mavlink-core/src/connection/udp/config.rs @@ -34,7 +34,7 @@ pub struct UdpConfig { impl UdpConfig { /// Creates a UDP connection address. /// - /// The type of connection depends on the [`UdpMode`] + /// The type of connection depends on the [`UdpMode`]. pub fn new(address: String, mode: UdpMode) -> Self { Self { address, diff --git a/mavlink-core/src/error.rs b/mavlink-core/src/error.rs index 6f4d551cc6a..b12ce48a671 100644 --- a/mavlink-core/src/error.rs +++ b/mavlink-core/src/error.rs @@ -6,11 +6,11 @@ use std::error::Error; /// Error while parsing a MAVLink message #[derive(Debug)] pub enum ParserError { - /// Bit flag for this type is invalid + /// Bit flag for this type is invalid. InvalidFlag { flag_type: &'static str, value: u64 }, - /// Enum value for this enum type does not exist + /// Enum value for this enum type does not exist. InvalidEnum { enum_type: &'static str, value: u64 }, - /// Message ID does not exist in this message set + /// Message ID does not exist in this message set. UnknownMessage { id: u32 }, /// Errors that occurred in the bytes module. BytesError(bytes::Error), @@ -45,13 +45,13 @@ impl Error for ParserError {} /// Error while reading and parsing a MAVLink message #[derive(Debug)] pub enum MessageReadError { - /// IO Error while reading + /// An IO error occured while reading. #[cfg(feature = "std")] Io(std::io::Error), - /// IO Error while reading + /// An IO error occured while reading. #[cfg(all(feature = "embedded", not(feature = "std")))] Io, - /// Error while parsing + /// An error occured while parsing. Parse(ParserError), } @@ -95,13 +95,13 @@ impl From for MessageReadError { /// Error while writing a MAVLink message #[derive(Debug)] pub enum MessageWriteError { - /// IO Error while writing + /// An IO error occured while writing. #[cfg(feature = "std")] Io(std::io::Error), - /// IO Error while writing + /// An IO error occured while writing. #[cfg(all(feature = "embedded", not(feature = "std")))] Io, - /// Message does not support MAVLink 1 + /// The message does not support MAVLink 1. MAVLink2Only, } diff --git a/mavlink-core/src/lib.rs b/mavlink-core/src/lib.rs index a1e3e203a53..527896587db 100644 --- a/mavlink-core/src/lib.rs +++ b/mavlink-core/src/lib.rs @@ -166,7 +166,7 @@ pub use connection::file::config::FileConfig; /// Maximum size of any MAVLink frame in bytes. /// -/// This is a v2 frame with maximum payload size and a signature: +/// This is a v2 frame with maximum payload size and a signature: . pub const MAX_FRAME_SIZE: usize = 280; /// A MAVLink message payload @@ -177,26 +177,26 @@ pub trait Message where Self: Sized, { - /// MAVLink message ID + /// Returns the MAVLink message ID. fn message_id(&self) -> u32; - /// MAVLink message name + /// Returns the MAVLink message name. fn message_name(&self) -> &'static str; - /// Target system ID if the message is directed to a specific system + /// Returns target system ID if the message is directed to a specific system. fn target_system_id(&self) -> Option; - /// Target component ID if the message is directed to a specific component + /// Returns target component ID if the message is directed to a specific component. fn target_component_id(&self) -> Option; - /// Serialize **Message** into byte slice and return count of bytes written + /// Serialize **Message** into byte slice and return count of bytes written. /// /// # Panics /// - /// Will panic if the buffer provided is to small to store this message + /// Will panic if the buffer provided is to small to store this message. fn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize; - /// Parse a Message from its message id and payload bytes + /// Parse a Message from its message id and payload bytes. /// /// # Errors /// @@ -206,14 +206,14 @@ where /// [`UnknownMessage`]: ParserError::UnknownMessage fn parse(version: MavlinkVersion, msgid: u32, payload: &[u8]) -> Result; - /// Return message id of specific message name + /// Returns message id for specific message name. fn message_id_from_name(name: &str) -> Option; - /// Return a default message of the speicfied message id + /// Returns a default message of the specified message id. fn default_message_from_id(id: u32) -> Option; - /// Return random valid message of the speicfied message id + /// Returns random valid message of the specified message id. #[cfg(feature = "arbitrary")] fn random_message_from_id(id: u32, rng: &mut R) -> Option; - /// Return a message types [CRC_EXTRA byte](https://mavlink.io/en/guide/serialization.html#crc_extra) + /// Returns a message types [CRC_EXTRA byte](https://mavlink.io/en/guide/serialization.html#crc_extra). fn extra_crc(id: u32) -> u8; } @@ -227,12 +227,12 @@ pub trait MessageData: Sized { /// # Panics /// - /// Will panic if the buffer provided is to small to hold the full message payload of the implementing message type + /// Will panic if the buffer provided is to small to hold the full message payload of the implementing message type. fn ser(&self, version: MavlinkVersion, payload: &mut [u8]) -> usize; /// # Errors /// /// Will return [`ParserError::InvalidEnum`] on a nonexistent enum value and - /// [`ParserError::InvalidFlag`] on an invalid bitflag value + /// [`ParserError::InvalidFlag`] on an invalid bitflag value. fn deser(version: MavlinkVersion, payload: &[u8]) -> Result; } @@ -249,7 +249,7 @@ pub struct MavHeader { pub sequence: u8, } -/// [Versions of the MAVLink](https://mavlink.io/en/guide/mavlink_version.html) protocol that we support +/// [Versions of the MAVLink protocol](https://mavlink.io/en/guide/mavlink_version.html) that we support #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Serialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] @@ -290,7 +290,7 @@ pub struct MavFrame { pub header: MavHeader, /// Parsed [`Message`] payload pub msg: M, - /// Messages MAVLink version + /// Message's MAVLink version pub protocol_version: MavlinkVersion, } @@ -353,7 +353,7 @@ impl MavFrame { /// # Errors /// /// Will return a [`ParserError`] if a message was found but could not be parsed - /// or the if the buffer provided does not contain a full message + /// or the if the buffer provided does not contain a full message. pub fn deser(version: MavlinkVersion, input: &[u8]) -> Result { let mut buf = Bytes::new(input); @@ -387,7 +387,7 @@ impl MavFrame { }) } - /// Return the frame header + /// Returns the frame header. pub fn header(&self) -> MavHeader { self.header } @@ -405,9 +405,9 @@ pub fn calculate_crc(data: &[u8], extra_crc: u8) -> u16 { #[derive(Debug, Clone, Copy, PartialEq, Eq)] /// MAVLink Version selection when attempting to read pub enum ReadVersion { - /// Only attempt to read using a single MAVLink version + /// Only attempt to read using a single MAVLink version. Single(MavlinkVersion), - /// Attempt to read messages from both MAVLink versions + /// Attempt to read messages from both MAVLink versions. Any, } @@ -440,7 +440,7 @@ impl From for ReadVersion { /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). pub fn read_versioned_msg( r: &mut PeekReader, version: ReadVersion, @@ -456,7 +456,7 @@ pub fn read_versioned_msg( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). pub fn read_versioned_raw_message( r: &mut PeekReader, version: ReadVersion, @@ -476,7 +476,7 @@ pub fn read_versioned_raw_message( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "tokio")] pub async fn read_versioned_msg_async( r: &mut AsyncPeekReader, @@ -493,7 +493,7 @@ pub async fn read_versioned_msg_async( r: &mut AsyncPeekReader, @@ -517,7 +517,7 @@ pub async fn read_versioned_raw_message_async( r: &mut PeekReader, @@ -542,7 +542,7 @@ pub fn read_versioned_raw_message_signed( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "mav2-message-signing")] pub fn read_versioned_msg_signed( r: &mut PeekReader, @@ -563,7 +563,7 @@ pub fn read_versioned_msg_signed( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(all(feature = "tokio", feature = "mav2-message-signing"))] pub async fn read_versioned_raw_message_async_signed< M: Message, @@ -591,7 +591,7 @@ pub async fn read_versioned_raw_message_async_signed< /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(all(feature = "tokio", feature = "mav2-message-signing"))] pub async fn read_versioned_msg_async_signed( r: &mut AsyncPeekReader, @@ -651,56 +651,56 @@ impl MAVLinkV1MessageRaw { self.0 } - /// Reference to the 5 byte header slice of the message + /// Returns a reference to the 5 byte header slice of the message. #[inline] pub fn header(&self) -> &[u8] { &self.0[1..=Self::HEADER_SIZE] } - /// Mutable reference to the 5 byte header slice of the message + /// Returns a mutable reference to the 5 byte header slice of the message. #[inline] fn mut_header(&mut self) -> &mut [u8] { &mut self.0[1..=Self::HEADER_SIZE] } - /// Size of the payload of the message + /// Returns the size of the payload of the message. #[inline] pub fn payload_length(&self) -> u8 { self.0[1] } - /// Packet sequence number + /// Returns the packet sequence number. #[inline] pub fn sequence(&self) -> u8 { self.0[2] } - /// Message sender System ID + /// Returns the message sender's system ID. #[inline] pub fn system_id(&self) -> u8 { self.0[3] } - /// Message sender Component ID + /// Returns the message sender's component ID. #[inline] pub fn component_id(&self) -> u8 { self.0[4] } - /// Message ID + /// Returns the message ID. #[inline] pub fn message_id(&self) -> u8 { self.0[5] } - /// Reference to the payload byte slice of the message + /// Returns a reference to the payload byte slice of the message. #[inline] pub fn payload(&self) -> &[u8] { let payload_length: usize = self.payload_length().into(); &self.0[(1 + Self::HEADER_SIZE)..(1 + Self::HEADER_SIZE + payload_length)] } - /// [CRC-16 checksum](https://mavlink.io/en/guide/serialization.html#checksum) field of the message + /// Returns the [CRC-16 checksum](https://mavlink.io/en/guide/serialization.html#checksum) field of the message. #[inline] pub fn checksum(&self) -> u16 { let payload_length: usize = self.payload_length().into(); @@ -727,7 +727,7 @@ impl MAVLinkV1MessageRaw { ) } - /// Raw byte slice of the message + /// Returns the raw byte slice of the message. pub fn raw_bytes(&self) -> &[u8] { let payload_length = self.payload_length() as usize; &self.0[..(1 + Self::HEADER_SIZE + payload_length + 2)] @@ -735,7 +735,7 @@ impl MAVLinkV1MessageRaw { /// # Panics /// - /// If the `msgid` parameter exceeds 255 and is therefore not supported for MAVLink 1 + /// If the `msgid` parameter exceeds 255 and is therefore not supported for MAVLink 1. fn serialize_stx_and_header_and_crc( &mut self, header: MavHeader, @@ -767,7 +767,7 @@ impl MAVLinkV1MessageRaw { /// /// # Panics /// - /// If the message's id exceeds 255 and is therefore not supported for MAVLink 1 + /// If the message's id exceeds 255 and is therefore not supported for MAVLink 1. pub fn serialize_message(&mut self, header: MavHeader, message: &M) { let payload_buf = &mut self.0[(1 + Self::HEADER_SIZE)..(1 + Self::HEADER_SIZE + 255)]; let payload_length = message.ser(MavlinkVersion::V1, payload_buf); @@ -783,7 +783,7 @@ impl MAVLinkV1MessageRaw { /// # Panics /// - /// If the `MessageData`'s `ID` exceeds 255 and is therefore not supported for MAVLink 1 + /// If the `MessageData`'s `ID` exceeds 255 and is therefore not supported for MAVLink 1. pub fn serialize_message_data(&mut self, header: MavHeader, message_data: &D) { let payload_buf = &mut self.0[(1 + Self::HEADER_SIZE)..(1 + Self::HEADER_SIZE + 255)]; let payload_length = message_data.ser(MavlinkVersion::V1, payload_buf); @@ -849,7 +849,7 @@ async fn try_decode_v1_async( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). pub fn read_v1_raw_message( reader: &mut PeekReader, ) -> Result { @@ -871,7 +871,7 @@ pub fn read_v1_raw_message( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "tokio")] pub async fn read_v1_raw_message_async( reader: &mut AsyncPeekReader, @@ -890,7 +890,8 @@ pub async fn read_v1_raw_message_async` /// /// # Example @@ -937,7 +938,7 @@ pub async fn read_v1_raw_message_async( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). pub fn read_v1_msg( r: &mut PeekReader, ) -> Result<(MavHeader, M), MessageReadError> { @@ -961,7 +962,7 @@ pub fn read_v1_msg( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "tokio")] pub async fn read_v1_msg_async( r: &mut AsyncPeekReader, @@ -1058,25 +1059,25 @@ impl MAVLinkV2MessageRaw { self.0 } - /// Reference to the 9 byte header slice of the message + /// Returns a reference to the 9 byte header slice of the message. #[inline] pub fn header(&self) -> &[u8] { &self.0[1..=Self::HEADER_SIZE] } - /// Mutable reference to the header byte slice of the message + /// Returns a mutable reference to the header byte slice of the message. #[inline] fn mut_header(&mut self) -> &mut [u8] { &mut self.0[1..=Self::HEADER_SIZE] } - /// Size of the payload of the message + /// Returns the size of the payload of the message. #[inline] pub fn payload_length(&self) -> u8 { self.0[1] } - /// [Incompatiblity flags](https://mavlink.io/en/guide/serialization.html#incompat_flags) of the message + /// Returns the [incompatiblity flags](https://mavlink.io/en/guide/serialization.html#incompat_flags) of the message. /// /// Currently the only supported incompatebility flag is `MAVLINK_IFLAG_SIGNED`. #[inline] @@ -1084,7 +1085,7 @@ impl MAVLinkV2MessageRaw { self.0[2] } - /// Mutable reference to the [incompatiblity flags](https://mavlink.io/en/guide/serialization.html#incompat_flags) of the message + /// Returns a mutable reference to the [incompatiblity flags](https://mavlink.io/en/guide/serialization.html#incompat_flags) of the message. /// /// Currently the only supported incompatebility flag is `MAVLINK_IFLAG_SIGNED`. #[inline] @@ -1092,44 +1093,44 @@ impl MAVLinkV2MessageRaw { &mut self.0[2] } - /// [Compatibility Flags](https://mavlink.io/en/guide/serialization.html#compat_flags) of the message + /// Returns the [compatibility flags](https://mavlink.io/en/guide/serialization.html#compat_flags) of the message. #[inline] pub fn compatibility_flags(&self) -> u8 { self.0[3] } - /// Packet sequence number + /// Returns the packet sequence number. #[inline] pub fn sequence(&self) -> u8 { self.0[4] } - /// Message sender System ID + /// Returns the message sender's system ID. #[inline] pub fn system_id(&self) -> u8 { self.0[5] } - /// Message sender Component ID + /// Returns the message sender's component ID. #[inline] pub fn component_id(&self) -> u8 { self.0[6] } - /// Message ID + /// Returns the message ID. #[inline] pub fn message_id(&self) -> u32 { u32::from_le_bytes([self.0[7], self.0[8], self.0[9], 0]) } - /// Reference to the payload byte slice of the message + /// Returns a reference to the payload byte slice of the message. #[inline] pub fn payload(&self) -> &[u8] { let payload_length: usize = self.payload_length().into(); &self.0[(1 + Self::HEADER_SIZE)..(1 + Self::HEADER_SIZE + payload_length)] } - /// [CRC-16 checksum](https://mavlink.io/en/guide/serialization.html#checksum) field of the message + /// Returns the [CRC-16 checksum](https://mavlink.io/en/guide/serialization.html#checksum) field of the message. #[inline] pub fn checksum(&self) -> u16 { let payload_length: usize = self.payload_length().into(); @@ -1139,7 +1140,7 @@ impl MAVLinkV2MessageRaw { ]) } - /// Reference to the 2 checksum bytes of the message + /// Returns a reference to the 2 checksum bytes of the message. #[cfg(feature = "mav2-message-signing")] #[inline] pub fn checksum_bytes(&self) -> &[u8] { @@ -1147,7 +1148,7 @@ impl MAVLinkV2MessageRaw { &self.0[checksum_offset..(checksum_offset + 2)] } - /// Signature [Link ID](https://mavlink.io/en/guide/message_signing.html#link_ids) + /// Returns the signature [Link ID](https://mavlink.io/en/guide/message_signing.html#link_ids). /// /// If the message is not signed this 0. #[cfg(feature = "mav2-message-signing")] @@ -1157,7 +1158,7 @@ impl MAVLinkV2MessageRaw { self.0[1 + Self::HEADER_SIZE + payload_length + 2] } - /// Mutable reference to the signature [Link ID](https://mavlink.io/en/guide/message_signing.html#link_ids) + /// Returns a mutable reference to the signature [Link ID](https://mavlink.io/en/guide/message_signing.html#link_ids). #[cfg(feature = "mav2-message-signing")] #[inline] pub fn signature_link_id_mut(&mut self) -> &mut u8 { @@ -1165,7 +1166,7 @@ impl MAVLinkV2MessageRaw { &mut self.0[1 + Self::HEADER_SIZE + payload_length + 2] } - /// Message [signature timestamp](https://mavlink.io/en/guide/message_signing.html#timestamp) + /// Returns the message's [signature timestamp](https://mavlink.io/en/guide/message_signing.html#timestamp). /// /// The timestamp is a 48 bit number with units of 10 microseconds since 1st January 2015 GMT. /// The offset since 1st January 1970 (the unix epoch) is 1420070400 seconds. @@ -1178,7 +1179,7 @@ impl MAVLinkV2MessageRaw { u64::from_le_bytes(timestamp_bytes) } - /// 48 bit [signature timestamp](https://mavlink.io/en/guide/message_signing.html#timestamp) byte slice + /// Returns the 48 bit [signature timestamp](https://mavlink.io/en/guide/message_signing.html#timestamp) byte slice. /// /// If the message is not signed this contains zeros. #[cfg(feature = "mav2-message-signing")] @@ -1189,7 +1190,7 @@ impl MAVLinkV2MessageRaw { &self.0[timestamp_start..(timestamp_start + 6)] } - /// Mutable reference to the 48 bit signature timestams byte slice + /// Returns a mutable reference to the 48 bit signature timestams byte slice. #[cfg(feature = "mav2-message-signing")] #[inline] pub fn signature_timestamp_bytes_mut(&mut self) -> &mut [u8] { @@ -1198,7 +1199,7 @@ impl MAVLinkV2MessageRaw { &mut self.0[timestamp_start..(timestamp_start + 6)] } - /// Reference to the 48 bit [message signature](https://mavlink.io/en/guide/message_signing.html#signature) byte slice + /// Returns a reference to the 48 bit [message signature](https://mavlink.io/en/guide/message_signing.html#signature) byte slice. /// /// If the message is not signed this contains zeros. #[cfg(feature = "mav2-message-signing")] @@ -1209,7 +1210,7 @@ impl MAVLinkV2MessageRaw { &self.0[signature_start..(signature_start + 6)] } - /// Mutable reference to the 48 bit [message signature](https://mavlink.io/en/guide/message_signing.html#signature) byte slice + /// Returns a mutable reference to the 48 bit [message signature](https://mavlink.io/en/guide/message_signing.html#signature) byte slice. #[cfg(feature = "mav2-message-signing")] #[inline] pub fn signature_value_mut(&mut self) -> &mut [u8] { @@ -1259,7 +1260,7 @@ impl MAVLinkV2MessageRaw { target_buffer.copy_from_slice(&hasher.finalize()[0..6]); } - /// Raw byte slice of the message + /// Retuns raw byte slice of the message. pub fn raw_bytes(&self) -> &[u8] { let payload_length = self.payload_length() as usize; @@ -1438,7 +1439,7 @@ async fn try_decode_v2_async( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[inline] pub fn read_v2_raw_message( reader: &mut PeekReader, @@ -1450,7 +1451,7 @@ pub fn read_v2_raw_message( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "mav2-message-signing")] #[inline] pub fn read_v2_raw_message_signed( @@ -1481,7 +1482,7 @@ fn read_v2_raw_message_inner( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "tokio")] pub async fn read_v2_raw_message_async( reader: &mut AsyncPeekReader, @@ -1509,11 +1510,11 @@ async fn read_v2_raw_message_async_inner( reader: &mut AsyncPeekReader, @@ -1574,7 +1575,7 @@ pub async fn read_v2_raw_message_async( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[inline] pub fn read_v2_msg( read: &mut PeekReader, @@ -1586,7 +1587,7 @@ pub fn read_v2_msg( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "mav2-message-signing")] #[inline] pub fn read_v2_msg_signed( @@ -1616,7 +1617,7 @@ fn read_v2_msg_inner( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "tokio")] pub async fn read_v2_msg_async( read: &mut AsyncPeekReader, @@ -1628,7 +1629,7 @@ pub async fn read_v2_msg_async( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(all(feature = "tokio", feature = "mav2-message-signing"))] pub async fn read_v2_msg_async_signed( read: &mut AsyncPeekReader, @@ -1678,7 +1679,7 @@ pub async fn read_v2_msg_async( )) } -/// Raw byte representation of a MAVLink message of either version +/// Raw byte representation of a MAVLink message of either version. pub enum MAVLinkMessageRaw { V1(MAVLinkV1MessageRaw), V2(MAVLinkV2MessageRaw), @@ -1727,7 +1728,7 @@ impl MAVLinkMessageRaw { /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[inline] pub fn read_any_raw_message( reader: &mut PeekReader, @@ -1739,7 +1740,7 @@ pub fn read_any_raw_message( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "mav2-message-signing")] #[inline] pub fn read_any_raw_message_signed( @@ -1797,7 +1798,7 @@ fn read_any_raw_message_inner( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "tokio")] pub async fn read_any_raw_message_async( reader: &mut AsyncPeekReader, @@ -1811,7 +1812,7 @@ pub async fn read_any_raw_message_async( reader: &mut AsyncPeekReader, @@ -1867,7 +1868,7 @@ async fn read_any_raw_message_async_inner( read: &mut PeekReader, @@ -1881,7 +1882,7 @@ pub fn read_any_msg( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "mav2-message-signing")] #[inline] pub fn read_any_msg_signed( @@ -1910,7 +1911,7 @@ fn read_any_msg_inner( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(feature = "tokio")] pub async fn read_any_msg_async( read: &mut AsyncPeekReader, @@ -1924,7 +1925,7 @@ pub async fn read_any_msg_async( /// /// # Errors /// -/// See [`read_` function error documentation](crate#read-errors) +/// See [`read_` function error documentation](crate#read-errors). #[cfg(all(feature = "tokio", feature = "mav2-message-signing"))] #[inline] pub async fn read_any_msg_async_signed( diff --git a/mavlink-core/src/peek_reader.rs b/mavlink-core/src/peek_reader.rs index 0405b9b3fb6..0114325c1df 100644 --- a/mavlink-core/src/peek_reader.rs +++ b/mavlink-core/src/peek_reader.rs @@ -30,7 +30,7 @@ use crate::error::MessageReadError; /// to `read` bytes (consuming them), or to `consume` them after `peek`ing. /// /// NOTE: This reader is generic over the size of the buffer, defaulting to MAVLink's current largest -/// possible message size of 280 bytes +/// possible message size of 280 bytes. /// pub struct PeekReader { // Internal buffer @@ -44,7 +44,7 @@ pub struct PeekReader { } impl PeekReader { - /// Instantiates a new [`PeekReader`], wrapping the provided [`Read`]er and using the default chunk size + /// Instantiates a new [`PeekReader`], wrapping the provided [`Read`]er and using the default chunk size. pub fn new(reader: R) -> Self { Self { buffer: [0; BUFFER_SIZE], @@ -54,7 +54,7 @@ impl PeekReader { } } - /// Peeks an exact amount of bytes from the internal buffer + /// Peeks an exact amount of bytes from the internal buffer. /// /// If the internal buffer does not contain enough data, this function will read /// from the underlying [`Read`]er until it does, an error occurs or no more data can be read (EOF). @@ -69,13 +69,13 @@ impl PeekReader { /// /// # Panics /// - /// Will panic when attempting to read more bytes then `BUFFER_SIZE` + /// Will panic when attempting to read more bytes then `BUFFER_SIZE`. pub fn peek_exact(&mut self, amount: usize) -> Result<&[u8], MessageReadError> { let result = self.fetch(amount, false); result } - /// Reads a specified amount of bytes from the internal buffer + /// Reads a specified amount of bytes from the internal buffer. /// /// If the internal buffer does not contain enough data, this function will read /// from the underlying [`Read`]er until it does, an error occurs or no more data can be read (EOF). @@ -89,12 +89,12 @@ impl PeekReader { /// /// # Panics /// - /// Will panic when attempting to read more bytes then `BUFFER_SIZE` + /// Will panic when attempting to read more bytes then `BUFFER_SIZE`. pub fn read_exact(&mut self, amount: usize) -> Result<&[u8], MessageReadError> { self.fetch(amount, true) } - /// Reads a byte from the internal buffer + /// Reads a byte from the internal buffer. /// /// If the internal buffer does not contain enough data, this function will read /// from the underlying [`Read`]er until it does, an error occurs or no more data can be read (EOF). @@ -114,7 +114,7 @@ impl PeekReader { Ok(buf[0]) } - /// Consumes a specified amount of bytes from the buffer + /// Consumes a specified amount of bytes from the buffer. /// /// If the internal buffer does not contain enough data, this function will consume as much data as is buffered. /// @@ -124,21 +124,21 @@ impl PeekReader { amount } - /// Returns an immutable reference to the underlying [`Read`]er + /// Returns an immutable reference to the underlying [`Read`]er. /// - /// Reading directly from the underlying reader will cause data loss + /// Reading directly from the underlying reader will cause data loss. pub fn reader_ref(&self) -> &R { &self.reader } - /// Returns a mutable reference to the underlying [`Read`]er + /// Returns a mutable reference to the underlying [`Read`]er. /// - /// Reading directly from the underlying reader will cause data loss + /// Reading directly from the underlying reader will cause data loss. pub fn reader_mut(&mut self) -> &mut R { &mut self.reader } - /// Internal function to fetch data from the internal buffer and/or reader + /// Internal function that fetches data from the internal buffer and/or reader. fn fetch(&mut self, amount: usize, consume: bool) -> Result<&[u8], MessageReadError> { assert!(BUFFER_SIZE >= amount); diff --git a/mavlink-core/src/signing.rs b/mavlink-core/src/signing.rs index 7e691ea066a..17e378185c8 100644 --- a/mavlink-core/src/signing.rs +++ b/mavlink-core/src/signing.rs @@ -60,7 +60,7 @@ impl SigningConfig { } impl SigningData { - /// Initializes signing data from a given [`SigningConfig`] + /// Initializes signing data from a given [`SigningConfig`]. pub fn from_config(config: SigningConfig) -> Self { Self { config, diff --git a/mavlink-core/src/utils.rs b/mavlink-core/src/utils.rs index 0603c77f61d..0e27e21de40 100644 --- a/mavlink-core/src/utils.rs +++ b/mavlink-core/src/utils.rs @@ -1,6 +1,6 @@ //! Utilities for processing MAVLink messages -/// Removes the trailing zeroes in the payload +/// Removes the trailing zeroes in the payload. /// /// # Note: ///