diff --git a/veilid-core/src/component.rs b/veilid-core/src/component.rs index 5a4e55c5..380287a9 100644 --- a/veilid-core/src/component.rs +++ b/veilid-core/src/component.rs @@ -50,7 +50,7 @@ pub struct VeilidComponentGuard<'a, T: VeilidComponent + Send + Sync + 'static> _phantom: core::marker::PhantomData<&'a T>, } -impl<'a, T> core::ops::Deref for VeilidComponentGuard<'a, T> +impl core::ops::Deref for VeilidComponentGuard<'_, T> where T: VeilidComponent + Send + Sync + 'static, { diff --git a/veilid-core/src/crypto/envelope.rs b/veilid-core/src/crypto/envelope.rs index b495ec18..fcd04686 100644 --- a/veilid-core/src/crypto/envelope.rs +++ b/veilid-core/src/crypto/envelope.rs @@ -3,6 +3,10 @@ use super::*; use crate::*; use core::convert::TryInto; +pub const MAX_ENVELOPE_SIZE: usize = 65507; +pub const MIN_ENVELOPE_SIZE: usize = 0x6A + 0x40; // Header + Signature +pub const ENVELOPE_MAGIC: &[u8; 3] = b"VLD"; + /// Envelopes are versioned /// /// These are the formats for the on-the-wire serialization performed by this module @@ -29,11 +33,6 @@ use core::convert::TryInto; /// signature: [u8; 64], // 0x?? (end-0x40): Signature of the entire envelope including header is appended to the packet /// // entire header needs to be included in message digest, relays are not allowed to modify the envelope without invalidating the signature. /// } - -pub const MAX_ENVELOPE_SIZE: usize = 65507; -pub const MIN_ENVELOPE_SIZE: usize = 0x6A + 0x40; // Header + Signature -pub const ENVELOPE_MAGIC: &[u8; 3] = b"VLD"; - #[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct Envelope { version: EnvelopeVersion, diff --git a/veilid-core/src/crypto/guard.rs b/veilid-core/src/crypto/guard.rs index 6e52822a..5b970a2f 100644 --- a/veilid-core/src/crypto/guard.rs +++ b/veilid-core/src/crypto/guard.rs @@ -19,7 +19,7 @@ impl<'a> CryptoSystemGuard<'a> { } } -impl<'a> core::ops::Deref for CryptoSystemGuard<'a> { +impl core::ops::Deref for CryptoSystemGuard<'_> { type Target = dyn CryptoSystem + Send + Sync; fn deref(&self) -> &Self::Target { @@ -39,7 +39,7 @@ async fn yielding R>(x: T) -> R { out } -impl<'a> AsyncCryptoSystemGuard<'a> { +impl AsyncCryptoSystemGuard<'_> { // Accessors pub fn kind(&self) -> CryptoKind { self.guard.kind() diff --git a/veilid-core/src/crypto/receipt.rs b/veilid-core/src/crypto/receipt.rs index 02dca5c0..dda0ca34 100644 --- a/veilid-core/src/crypto/receipt.rs +++ b/veilid-core/src/crypto/receipt.rs @@ -3,6 +3,11 @@ use super::*; use crate::*; use core::convert::TryInto; +pub const MAX_RECEIPT_SIZE: usize = 1380; +pub const MAX_EXTRA_DATA_SIZE: usize = MAX_RECEIPT_SIZE - MIN_RECEIPT_SIZE; // 1250 +pub const MIN_RECEIPT_SIZE: usize = 130; +pub const RECEIPT_MAGIC: &[u8; 3] = b"RCP"; + /// Out-of-band receipts are versioned along with envelope versions /// /// These are the formats for the on-the-wire serialization performed by this module @@ -26,12 +31,6 @@ use core::convert::TryInto; /// extra_data: [u8; ??], // 0x42: Extra data is appended (arbitrary extra data, not encrypted by receipt itself, maximum size is 1250 bytes) /// signature: [u8; 64], // 0x?? (end-0x40): Signature of the entire receipt including header and extra data is appended to the packet /// } - -pub const MAX_RECEIPT_SIZE: usize = 1380; -pub const MAX_EXTRA_DATA_SIZE: usize = MAX_RECEIPT_SIZE - MIN_RECEIPT_SIZE; // 1250 -pub const MIN_RECEIPT_SIZE: usize = 130; -pub const RECEIPT_MAGIC: &[u8; 3] = b"RCP"; - #[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct Receipt { version: u8, diff --git a/veilid-core/src/logging/fmt_strip_fields.rs b/veilid-core/src/logging/fmt_strip_fields.rs index 0c1f1de3..6c910031 100644 --- a/veilid-core/src/logging/fmt_strip_fields.rs +++ b/veilid-core/src/logging/fmt_strip_fields.rs @@ -53,7 +53,7 @@ where } } -impl<'a, F, Out> VisitOutput for FmtStripVisitor<'a, F, Out> +impl VisitOutput for FmtStripVisitor<'_, F, Out> where F: Visit + VisitOutput, { @@ -70,7 +70,7 @@ where } } -impl<'a, F, Out> Visit for FmtStripVisitor<'a, F, Out> +impl Visit for FmtStripVisitor<'_, F, Out> where F: Visit + VisitOutput, { diff --git a/veilid-core/src/network_manager/address_check.rs b/veilid-core/src/network_manager/address_check.rs index a28e67b3..2fe10819 100644 --- a/veilid-core/src/network_manager/address_check.rs +++ b/veilid-core/src/network_manager/address_check.rs @@ -13,7 +13,7 @@ pub const ADDRESS_CONSISTENCY_DETECTION_COUNT: usize = 5; /// Length of consistent/inconsistent result cache for detection pub const ADDRESS_CHECK_CACHE_SIZE: usize = 10; -/// Length of consistent/inconsistent result cache for detection +// /// Length of consistent/inconsistent result cache for detection // pub const ADDRESS_CHECK_PEER_COUNT: usize = 256; // /// Frequency of address checks // pub const PUBLIC_ADDRESS_CHECK_TASK_INTERVAL_SECS: u32 = 60; diff --git a/veilid-core/src/network_manager/connection_manager.rs b/veilid-core/src/network_manager/connection_manager.rs index c63e34be..89030eeb 100644 --- a/veilid-core/src/network_manager/connection_manager.rs +++ b/veilid-core/src/network_manager/connection_manager.rs @@ -521,7 +521,7 @@ impl ConnectionManager { } /////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Asynchronous Event Processor + // Asynchronous Event Processor async fn process_connection_manager_event( &self, diff --git a/veilid-core/src/network_manager/native/start_protocols.rs b/veilid-core/src/network_manager/native/start_protocols.rs index f430ef39..a8e82c53 100644 --- a/veilid-core/src/network_manager/native/start_protocols.rs +++ b/veilid-core/src/network_manager/native/start_protocols.rs @@ -351,7 +351,7 @@ impl Network { // Add static public dialinfo if it's configured if let Some(url) = url.as_ref() { let mut split_url = SplitUrl::from_str(url).wrap_err("couldn't split url")?; - if split_url.scheme.to_ascii_lowercase() != "ws" { + if !split_url.scheme.eq_ignore_ascii_case("ws") { bail!("WS URL must use 'ws://' scheme"); } "ws".clone_into(&mut split_url.scheme); @@ -478,7 +478,7 @@ impl Network { if let Some(url) = url.as_ref() { // Add static public dialinfo if it's configured let mut split_url = SplitUrl::from_str(url)?; - if split_url.scheme.to_ascii_lowercase() != "wss" { + if !split_url.scheme.eq_ignore_ascii_case("wss") { bail!("WSS URL must use 'wss://' scheme"); } "wss".clone_into(&mut split_url.scheme); diff --git a/veilid-core/src/routing_table/bucket_entry.rs b/veilid-core/src/routing_table/bucket_entry.rs index d97ffcca..22ed6b25 100644 --- a/veilid-core/src/routing_table/bucket_entry.rs +++ b/veilid-core/src/routing_table/bucket_entry.rs @@ -981,7 +981,7 @@ impl BucketEntryInner { self.peer_stats.rpc_stats.last_question_ts } - /// Return the last time we asked a node a question + // /// Return the last time we asked a node a question // fn last_question_time(&self) -> Option { // self.peer_stats.rpc_stats.last_question_ts // } @@ -1112,7 +1112,7 @@ impl BucketEntryInner { } //////////////////////////////////////////////////////////////// - /// Called when rpc processor things happen + // Called when rpc processor things happen pub(super) fn question_sent( &mut self, diff --git a/veilid-core/src/routing_table/mod.rs b/veilid-core/src/routing_table/mod.rs index 7fe044bb..92ea734c 100644 --- a/veilid-core/src/routing_table/mod.rs +++ b/veilid-core/src/routing_table/mod.rs @@ -209,7 +209,7 @@ impl RoutingTable { } ///////////////////////////////////// - /// Initialization + // Initialization /// Called to initialize the routing table after it is created async fn init_async(&self) -> EyreResult<()> { @@ -517,7 +517,7 @@ impl RoutingTable { } ///////////////////////////////////// - /// Locked operations + // Locked operations pub fn routing_domain_for_address(&self, address: Address) -> Option { self.inner.read().routing_domain_for_address(address) diff --git a/veilid-core/src/routing_table/node_ref/node_ref_lock.rs b/veilid-core/src/routing_table/node_ref/node_ref_lock.rs index d07a8abf..ee33c294 100644 --- a/veilid-core/src/routing_table/node_ref/node_ref_lock.rs +++ b/veilid-core/src/routing_table/node_ref/node_ref_lock.rs @@ -16,14 +16,13 @@ pub(crate) struct NodeRefLock< } impl< - 'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + VeilidComponentRegistryAccessor + fmt::Debug + fmt::Display + Clone, - > VeilidComponentRegistryAccessor for NodeRefLock<'a, N> + > VeilidComponentRegistryAccessor for NodeRefLock<'_, N> { fn registry(&self) -> VeilidComponentRegistry { self.nr.registry() @@ -45,8 +44,8 @@ impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Disp } } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - NodeRefAccessorsTrait for NodeRefLock<'a, N> +impl + NodeRefAccessorsTrait for NodeRefLock<'_, N> { fn entry(&self) -> Arc { self.nr.entry() @@ -73,8 +72,8 @@ impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Disp } } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - NodeRefOperateTrait for NodeRefLock<'a, N> +impl + NodeRefOperateTrait for NodeRefLock<'_, N> { fn operate(&self, f: F) -> T where @@ -107,21 +106,21 @@ impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Disp } } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - NodeRefCommonTrait for NodeRefLock<'a, N> +impl + NodeRefCommonTrait for NodeRefLock<'_, N> { } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - fmt::Display for NodeRefLock<'a, N> +impl + fmt::Display for NodeRefLock<'_, N> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.nr) } } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - fmt::Debug for NodeRefLock<'a, N> +impl + fmt::Debug for NodeRefLock<'_, N> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("NodeRefLock").field("nr", &self.nr).finish() diff --git a/veilid-core/src/routing_table/node_ref/node_ref_lock_mut.rs b/veilid-core/src/routing_table/node_ref/node_ref_lock_mut.rs index 8b0acb9b..ce462deb 100644 --- a/veilid-core/src/routing_table/node_ref/node_ref_lock_mut.rs +++ b/veilid-core/src/routing_table/node_ref/node_ref_lock_mut.rs @@ -16,14 +16,13 @@ pub(crate) struct NodeRefLockMut< } impl< - 'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + VeilidComponentRegistryAccessor + fmt::Debug + fmt::Display + Clone, - > VeilidComponentRegistryAccessor for NodeRefLockMut<'a, N> + > VeilidComponentRegistryAccessor for NodeRefLockMut<'_, N> { fn registry(&self) -> VeilidComponentRegistry { self.nr.registry() @@ -46,8 +45,8 @@ impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Disp } } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - NodeRefAccessorsTrait for NodeRefLockMut<'a, N> +impl + NodeRefAccessorsTrait for NodeRefLockMut<'_, N> { fn entry(&self) -> Arc { self.nr.entry() @@ -74,8 +73,8 @@ impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Disp } } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - NodeRefOperateTrait for NodeRefLockMut<'a, N> +impl + NodeRefOperateTrait for NodeRefLockMut<'_, N> { fn operate(&self, f: F) -> T where @@ -110,21 +109,21 @@ impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Disp } } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - NodeRefCommonTrait for NodeRefLockMut<'a, N> +impl + NodeRefCommonTrait for NodeRefLockMut<'_, N> { } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - fmt::Display for NodeRefLockMut<'a, N> +impl + fmt::Display for NodeRefLockMut<'_, N> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.nr) } } -impl<'a, N: NodeRefAccessorsTrait + NodeRefOperateTrait + fmt::Debug + fmt::Display + Clone> - fmt::Debug for NodeRefLockMut<'a, N> +impl + fmt::Debug for NodeRefLockMut<'_, N> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("NodeRefLockMut") diff --git a/veilid-core/src/routing_table/routing_table_inner/mod.rs b/veilid-core/src/routing_table/routing_table_inner/mod.rs index 58bf5f40..61f25a21 100644 --- a/veilid-core/src/routing_table/routing_table_inner/mod.rs +++ b/veilid-core/src/routing_table/routing_table_inner/mod.rs @@ -1337,10 +1337,10 @@ impl RoutingTableInner { } // reliable nodes come first, pessimistically treating our own node as unreliable - let ra = a_entry.as_ref().map_or(false, |x| { + let ra = a_entry.as_ref().is_some_and(|x| { x.with_inner(|x| x.check_unreliable(cur_ts).is_none()) }); - let rb = b_entry.as_ref().map_or(false, |x| { + let rb = b_entry.as_ref().is_some_and(|x| { x.with_inner(|x| x.check_unreliable(cur_ts).is_none()) }); if ra != rb { diff --git a/veilid-core/src/routing_table/routing_table_inner/routing_domains/local_network/editor.rs b/veilid-core/src/routing_table/routing_table_inner/routing_domains/local_network/editor.rs index a3fdbe72..3ca49150 100644 --- a/veilid-core/src/routing_table/routing_table_inner/routing_domains/local_network/editor.rs +++ b/veilid-core/src/routing_table/routing_table_inner/routing_domains/local_network/editor.rs @@ -30,7 +30,7 @@ impl<'a> RoutingDomainEditorLocalNetwork<'a> { } } -impl<'a> RoutingDomainEditorCommonTrait for RoutingDomainEditorLocalNetwork<'a> { +impl RoutingDomainEditorCommonTrait for RoutingDomainEditorLocalNetwork<'_> { #[instrument(level = "debug", skip(self))] fn clear_dial_info_details( &mut self, diff --git a/veilid-core/src/routing_table/routing_table_inner/routing_domains/public_internet/editor.rs b/veilid-core/src/routing_table/routing_table_inner/routing_domains/public_internet/editor.rs index 9dfab66b..e8d3552d 100644 --- a/veilid-core/src/routing_table/routing_table_inner/routing_domains/public_internet/editor.rs +++ b/veilid-core/src/routing_table/routing_table_inner/routing_domains/public_internet/editor.rs @@ -41,7 +41,7 @@ impl<'a> RoutingDomainEditorPublicInternet<'a> { } } -impl<'a> RoutingDomainEditorCommonTrait for RoutingDomainEditorPublicInternet<'a> { +impl RoutingDomainEditorCommonTrait for RoutingDomainEditorPublicInternet<'_> { #[instrument(level = "debug", skip(self))] fn clear_dial_info_details( &mut self, diff --git a/veilid-core/src/routing_table/types/signed_node_info.rs b/veilid-core/src/routing_table/types/signed_node_info.rs index b59e5e67..4708774d 100644 --- a/veilid-core/src/routing_table/types/signed_node_info.rs +++ b/veilid-core/src/routing_table/types/signed_node_info.rs @@ -97,7 +97,7 @@ impl SignedNodeInfo { } } // Check our relay if we have one - return self + self .relay_info() .map(|relay_ni| { for did in relay_ni.dial_info_detail_list() { @@ -112,7 +112,7 @@ impl SignedNodeInfo { } false }) - .unwrap_or_default(); + .unwrap_or_default() } #[cfg(feature = "geolocation")] diff --git a/veilid-core/src/rpc_processor/mod.rs b/veilid-core/src/rpc_processor/mod.rs index 68bab229..309b429a 100644 --- a/veilid-core/src/rpc_processor/mod.rs +++ b/veilid-core/src/rpc_processor/mod.rs @@ -207,7 +207,7 @@ impl RPCProcessor { } ///////////////////////////////////// - /// Initialization + // Initialization #[expect(clippy::unused_async)] async fn init_async(&self) -> EyreResult<()> { diff --git a/veilid-core/src/veilid_api/routing_context.rs b/veilid-core/src/veilid_api/routing_context.rs index 07d90a85..a9ecbc2e 100644 --- a/veilid-core/src/veilid_api/routing_context.rs +++ b/veilid-core/src/veilid_api/routing_context.rs @@ -234,7 +234,7 @@ impl RoutingContext { } /////////////////////////////////// - /// DHT Records + // DHT Records /// Deterministicly builds the record key for a given schema and owner public key #[instrument(target = "veilid_api", level = "debug", fields(__VEILID_LOG_KEY = self.log_key()), ret, err)] diff --git a/veilid-core/src/veilid_api/types/aligned_u64.rs b/veilid-core/src/veilid_api/types/aligned_u64.rs index 7465d73d..d4afd280 100644 --- a/veilid-core/src/veilid_api/types/aligned_u64.rs +++ b/veilid-core/src/veilid_api/types/aligned_u64.rs @@ -5,7 +5,6 @@ use super::*; /// Required on 32-bit platforms for serialization because Rust aligns u64 on 4 byte boundaries. /// Some zero-copy serialization frameworks also want 8-byte alignment. /// Supports serializing to string for JSON as well, since JSON can't handle 64-bit numbers to Javascript. - macro_rules! aligned_u64_type { ($name:ident) => { #[derive( diff --git a/veilid-flutter/rust/src/dart_ffi.rs b/veilid-flutter/rust/src/dart_ffi.rs index cfd5c036..5eb3fdca 100644 --- a/veilid-flutter/rust/src/dart_ffi.rs +++ b/veilid-flutter/rust/src/dart_ffi.rs @@ -209,7 +209,7 @@ pub extern "C" fn initialize_veilid_flutter( } ////////////////////////////////////////////////////////////////////////////////// -/// C-compatible FFI Functions +// C-compatible FFI Functions #[no_mangle] #[instrument]