network: Put impl block directly under type
What changed, and why it matters
This commit simply moves existing code around in the same file. It places the main implementation block for the Network type directly underneath the type definition, which is a common Rust style preference. No behavior, logic, or security properties changed.
No action needed. This is a non-functional style/refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure reordering of impl blocks in network/src/lib.rs. The serde Serialize/Deserialize impls were moved below the inherent impl Network { … } block, and the inherent impl block was moved up directly after the Network enum definition. No code was added, removed, or modified; line counts are identical (+37/-37).
Changed components
network/src/lib.rsInspect captured patch +37 / −37
diff --git a/network/src/lib.rs b/network/src/lib.rs
index 55baf4c4..f974e88b 100644
--- a/network/src/lib.rs
+++ b/network/src/lib.rs
@@ -99,43 +99,6 @@ pub enum TestnetVersion {
V4,
}
-#[cfg(feature = "serde")]
-impl Serialize for Network {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_str(self.as_display_str())
- }
-}
-
-#[cfg(feature = "serde")]
-impl<'de> Deserialize<'de> for Network {
- fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
- where
- D: Deserializer<'de>,
- {
- struct NetworkVisitor;
-
- impl Visitor<'_> for NetworkVisitor {
- type Value = Network;
-
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("a valid network identifier")
- }
-
- fn visit_str<E>(self, value: &str) -> Result<Network, E>
- where
- E: serde::de::Error,
- {
- Network::from_str(value).map_err(E::custom)
- }
- }
-
- deserializer.deserialize_str(NetworkVisitor)
- }
-}
-
impl Network {
/// Converts to the equivalent Bitcoin Core `-chain` argument string.
///
@@ -188,6 +151,43 @@ impl Network {
}
}
+#[cfg(feature = "serde")]
+impl Serialize for Network {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_str(self.as_display_str())
+ }
+}
+
+#[cfg(feature = "serde")]
+impl<'de> Deserialize<'de> for Network {
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ struct NetworkVisitor;
+
+ impl Visitor<'_> for NetworkVisitor {
+ type Value = Network;
+
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ formatter.write_str("a valid network identifier")
+ }
+
+ fn visit_str<E>(self, value: &str) -> Result<Network, E>
+ where
+ E: serde::de::Error,
+ {
+ Network::from_str(value).map_err(E::custom)
+ }
+ }
+
+ deserializer.deserialize_str(NetworkVisitor)
+ }
+}
+
impl fmt::Display for Network {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "{}", self.as_display_str())
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.