Skip to content

Commit b7c5159

Browse files
committed
bless clippy and fix CI errors
Signed-off-by: Onur Özkan <work@onurozkan.dev>
1 parent e884999 commit b7c5159

16 files changed

Lines changed: 27 additions & 39 deletions

File tree

mavlink-bindgen/src/parser.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,13 @@ impl MavMessage {
916916

917917
#[inline(always)]
918918
fn emit_name_types(&self) -> (Vec<TokenStream>, usize) {
919-
let mut encoded_payload_len: usize = 0;
919+
let mut encoded_payload_size: usize = 0;
920920
let field_toks = self
921921
.fields
922922
.iter()
923923
.map(|field| {
924924
let nametype = field.emit_name_type();
925-
encoded_payload_len += field.mavtype.len();
925+
encoded_payload_size += field.mavtype.size();
926926

927927
let description = field.emit_description();
928928

@@ -960,7 +960,7 @@ impl MavMessage {
960960
}
961961
})
962962
.collect::<Vec<TokenStream>>();
963-
(field_toks, encoded_payload_len)
963+
(field_toks, encoded_payload_size)
964964
}
965965

966966
/// Generate description for the given message
@@ -1077,9 +1077,9 @@ impl MavMessage {
10771077
let id = self.id;
10781078
let name = self.name.clone();
10791079
let extra_crc = extra_crc(self);
1080-
let (name_types, payload_encoded_len) = self.emit_name_types();
1080+
let (name_types, payload_encoded_size) = self.emit_name_types();
10811081
assert!(
1082-
(1..=255).contains(&payload_encoded_len),
1082+
(1..=255).contains(&payload_encoded_size),
10831083
"payload length must be between 1 and 255 bytes"
10841084
);
10851085

@@ -1105,7 +1105,7 @@ impl MavMessage {
11051105
}
11061106

11071107
impl #msg_name {
1108-
pub const ENCODED_LEN: usize = #payload_encoded_len;
1108+
pub const ENCODED_LEN: usize = #payload_encoded_size;
11091109
#const_default
11101110

11111111
#[cfg(feature = "arbitrary")]
@@ -1126,7 +1126,7 @@ impl MavMessage {
11261126
const ID: u32 = #id;
11271127
const NAME: &'static str = #name;
11281128
const EXTRA_CRC: u8 = #extra_crc;
1129-
const ENCODED_LEN: usize = #payload_encoded_len;
1129+
const ENCODED_LEN: usize = #payload_encoded_size;
11301130

11311131
fn deser(_version: MavlinkVersion, __input: &[u8]) -> Result<Self, ::mavlink_core::error::ParserError> {
11321132
#deser_vars
@@ -1449,16 +1449,16 @@ impl MavType {
14491449
}
14501450
}
14511451

1452-
/// Size of a given Mavtype
1453-
pub fn len(&self) -> usize {
1452+
/// Encoded size of this MavType.
1453+
pub fn size(&self) -> usize {
14541454
use self::MavType::*;
14551455
match self {
14561456
UInt8MavlinkVersion | UInt8 | Int8 | Char => 1,
14571457
UInt16 | Int16 => 2,
14581458
UInt32 | Int32 | Float => 4,
14591459
UInt64 | Int64 | Double => 8,
14601460
CharArray(size) => *size,
1461-
Array(t, size) => t.len() * size,
1461+
Array(t, size) => t.size() * size,
14621462
}
14631463
}
14641464

@@ -1487,7 +1487,7 @@ impl MavType {
14871487
UInt16 | Int16 => 2,
14881488
UInt32 | Int32 | Float => 4,
14891489
UInt64 | Int64 | Double => 8,
1490-
Array(t, _) => t.len(),
1490+
Array(t, _) => t.size(),
14911491
}
14921492
}
14931493

mavlink-core/src/connection/direct_serial/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ mod sync;
33

44
#[cfg(feature = "tokio")]
55
mod r#async;
6-
7-
pub use sync::SerialConnection;

mavlink-core/src/connection/direct_serial/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Connectable for SerialConfig {
6969
Ok(Box::new(ConnectionCore::new_static(self.open()?)))
7070
}
7171

72-
fn connect_with_dialect<D: Dialect + 'static>(
72+
fn connect_with_dialect<D: Dialect + Send + Sync + 'static>(
7373
&self,
7474
dialect: D,
7575
) -> io::Result<DialectConnection<D>> {

mavlink-core/src/connection/file/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ mod sync;
33

44
#[cfg(feature = "tokio")]
55
mod r#async;
6-
7-
pub use sync::FileConnection;

mavlink-core/src/connection/file/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Connectable for FileConfig {
4848
Ok(Box::new(ConnectionCore::new_static(open(&self.address)?)))
4949
}
5050

51-
fn connect_with_dialect<D: Dialect + 'static>(
51+
fn connect_with_dialect<D: Dialect + Send + Sync + 'static>(
5252
&self,
5353
dialect: D,
5454
) -> io::Result<DialectConnection<D>> {

mavlink-core/src/connection/sync.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
};
1818

1919
/// The byte-oriented half of a blocking transport.
20-
pub(crate) trait SyncTransport {
20+
pub(crate) trait SyncTransport: Send + Sync {
2121
type Reader: Read;
2222
type Writer: Write;
2323

@@ -72,7 +72,7 @@ impl<T> ConnectionCore<T> {
7272
}
7373

7474
/// A MAVLink connection
75-
pub trait MavConnection<M> {
75+
pub trait MavConnection<M>: Send + Sync {
7676
/// Receive a MAVLink message.
7777
///
7878
/// May blocks until a valid frame is received, ignoring invalid messages.
@@ -259,7 +259,7 @@ macro_rules! impl_mav_connection {
259259
};
260260
}
261261

262-
impl_mav_connection!([T: SyncTransport, D: Dialect] ConnectionCore<T, D>, D::Message, |core| &core.dialect);
262+
impl_mav_connection!([T: SyncTransport, D: Dialect + Send + Sync] ConnectionCore<T, D>, D::Message, |core| &core.dialect);
263263
impl_mav_connection!([T: SyncTransport, M: Message] ConnectionCore<T>, M, |core| &StaticDialect::<M>::new());
264264

265265
/// A blocking MAVLink connection returned by [`connect`].
@@ -295,7 +295,7 @@ pub fn connect<M: Message + Sync + Send>(address: &str) -> io::Result<Connection
295295
/// Connect to a MAVLink node using a runtime-loaded dialect.
296296
///
297297
/// The accepted address formats and errors are the same as [`connect`].
298-
pub fn connect_with_dialect<D: Dialect + 'static>(
298+
pub fn connect_with_dialect<D: Dialect + Send + Sync + 'static>(
299299
address: &str,
300300
dialect: D,
301301
) -> io::Result<DialectConnection<D>> {
@@ -313,7 +313,7 @@ pub trait Connectable: Display {
313313
fn connect<M: Message>(&self) -> io::Result<Connection<M>>;
314314

315315
/// Attempt to establish a blocking MAVLink connection with a runtime-loaded dialect.
316-
fn connect_with_dialect<D: Dialect + 'static>(
316+
fn connect_with_dialect<D: Dialect + Send + Sync + 'static>(
317317
&self,
318318
dialect: D,
319319
) -> io::Result<DialectConnection<D>>;
@@ -332,7 +332,7 @@ impl Connectable for ConnectionAddress {
332332
}
333333
}
334334

335-
fn connect_with_dialect<D: Dialect + 'static>(
335+
fn connect_with_dialect<D: Dialect + Send + Sync + 'static>(
336336
&self,
337337
dialect: D,
338338
) -> io::Result<DialectConnection<D>> {

mavlink-core/src/connection/tcp/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ mod sync;
33

44
#[cfg(feature = "tokio")]
55
mod r#async;
6-
7-
pub use sync::TcpConnection;

mavlink-core/src/connection/tcp/sync.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ impl SyncTransport for TcpConnection {
9090
}
9191

9292
fn next_send_header(&self, writer: &mut Self::Writer, header: &MavHeader) -> MavHeader {
93-
let header = next_send_header(&mut writer.sequence, header);
94-
header
93+
next_send_header(&mut writer.sequence, header)
9594
}
9695
}
9796

@@ -109,7 +108,7 @@ impl Connectable for TcpConfig {
109108
Ok(Box::new(ConnectionCore::new_static(self.open()?)))
110109
}
111110

112-
fn connect_with_dialect<D: Dialect + 'static>(
111+
fn connect_with_dialect<D: Dialect + Send + Sync + 'static>(
113112
&self,
114113
dialect: D,
115114
) -> io::Result<DialectConnection<D>> {

mavlink-core/src/connection/udp/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ mod sync;
33

44
#[cfg(feature = "tokio")]
55
mod r#async;
6-
7-
pub use sync::UdpConnection;

mavlink-core/src/connection/udp/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Connectable for UdpConfig {
142142
fn connect<M: crate::Message>(&self) -> io::Result<Connection<M>> {
143143
Ok(Box::new(ConnectionCore::new_static(self.open()?)))
144144
}
145-
fn connect_with_dialect<D: Dialect + 'static>(
145+
fn connect_with_dialect<D: Dialect + Send + Sync + 'static>(
146146
&self,
147147
dialect: D,
148148
) -> io::Result<DialectConnection<D>> {

0 commit comments

Comments
 (0)