Skip to content

Commit b5863cc

Browse files
committed
style: improve code formatting and import organization
1 parent 7980b0f commit b5863cc

5 files changed

Lines changed: 18 additions & 17 deletions

File tree

examples/epmd_cli.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ fn main() -> orfail::Result<()> {
5757
Command::Names => {
5858
// 'NAMES_REQ'
5959
let names = client.get_names().await.or_fail()?;
60-
let result = serde_json::json!(names
61-
.into_iter()
62-
.map(|(name, port)| serde_json::json!({"name": name, "port": port}))
63-
.collect::<Vec<_>>());
60+
let result = serde_json::json!(
61+
names
62+
.into_iter()
63+
.map(|(name, port)| serde_json::json!({"name": name, "port": port}))
64+
.collect::<Vec<_>>()
65+
);
6466
println!("{}", serde_json::to_string_pretty(&result).or_fail()?);
6567
}
6668
Command::NodeEntry { node } => {

src/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use crate::DistributionFlags;
12
#[cfg(doc)]
23
use crate::handshake;
34
use crate::io::Connection;
45
use crate::message::Message;
5-
use crate::DistributionFlags;
66
use futures::io::{AsyncRead, AsyncWrite};
77

88
/// Makes a channel to send/received messages to/from a connected node.

src/epmd.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ impl std::fmt::Display for EpmdError {
142142
)
143143
}
144144
Self::MalformedNamesResponse { line } => {
145-
write!(f,"found a malformed NAMES_RESP line: expected_format=\"name {{NAME}} at port {{PORT}}\", actual_line={line:?}")
145+
write!(
146+
f,
147+
"found a malformed NAMES_RESP line: expected_format=\"name {{NAME}} at port {{PORT}}\", actual_line={line:?}"
148+
)
146149
}
147150
Self::Io(error) => write!(f, "{error}"),
148151
}

src/handshake.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ where
7272
return Err(HandshakeError::PhaseError {
7373
current: "ClientSideHandshake::execute_rest()",
7474
depends_on: "ClientSideHandshake::execute_send_name()",
75-
})
75+
});
7676
}
7777
Some(HandshakeStatus::Nok) => return Err(HandshakeError::OngoingHandshake),
7878
Some(HandshakeStatus::NotAllowed) => return Err(HandshakeError::NotAllowed),
@@ -201,7 +201,7 @@ where
201201
return Err(HandshakeError::UnexpectedTag {
202202
message: "CHALLENGE",
203203
tag,
204-
})
204+
});
205205
}
206206
};
207207
reader.finish().await?;
@@ -319,19 +319,15 @@ where
319319
return Err(HandshakeError::UnexpectedTag {
320320
message: "NAME",
321321
tag,
322-
})
322+
});
323323
}
324324
};
325325
reader.finish().await?;
326326

327327
let name = node.name.clone();
328328
let is_dynamic = node.flags.contains(DistributionFlags::NAME_ME);
329329
self.peer_node = Some(node);
330-
if is_dynamic {
331-
Ok(None)
332-
} else {
333-
Ok(Some(name))
334-
}
330+
if is_dynamic { Ok(None) } else { Ok(Some(name)) }
335331
}
336332

337333
/// Executes the rest part of the handshake protocol.

src/message.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
//! Reference: [Protocol between Connected Nodes](https://www.erlang.org/doc/apps/erts/erl_dist_protocol.html#protocol-between-connected-nodes)
44
//!
55
//! Note that distribution headers are not supported in the current version.
6+
#[cfg(doc)]
7+
use crate::DistributionFlags;
68
use crate::eetf_ext;
79
use crate::io::{ReadTermExt, WriteTermExt};
810
use crate::term::{Atom, FixInteger, List, Mfa, Pid, PidOrAtom, Reference, Term, Tuple};
9-
#[cfg(doc)]
10-
use crate::DistributionFlags;
1111
use eetf::{DecodeError, EncodeError};
1212
use std::io::{Read, Write};
1313

14-
pub use crate::channel::{channel, Receiver, RecvError, SendError, Sender};
14+
pub use crate::channel::{Receiver, RecvError, SendError, Sender, channel};
1515

1616
trait DistributionMessage: Sized {
1717
const OP: i32;

0 commit comments

Comments
 (0)