Skip to content

Commit

Permalink
refactor(lib): Simplify error handling in socket bind callback
Browse files Browse the repository at this point in the history
  • Loading branch information
rgbkrk committed Dec 13, 2024
1 parent d6957df commit 98f9217
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,16 @@ pub trait Socket: Sized + Send {
let endpoint = TryIntoEndpoint::try_into(endpoint)?;

let cloned_backend = self.backend();
let cback = move |result| {
let cback = move |result: ZmqResult<(FramedIo, Endpoint)>| {
let cloned_backend = cloned_backend.clone();
async move {
let result = match result {
Ok((socket, endpoint)) => {
match util::peer_connected(socket, cloned_backend.clone()).await {
Ok(peer_id) => Ok((endpoint, peer_id)),
Err(e) => Err(e),
}
}
Ok((socket, endpoint)) => util::peer_connected(socket, cloned_backend.clone())
.await
.map(|peer_id| (endpoint, peer_id)),
Err(e) => Err(e),
};

match result {
Ok((endpoint, peer_id)) => {
if let Some(monitor) = cloned_backend.monitor().lock().as_mut() {
Expand Down

0 comments on commit 98f9217

Please sign in to comment.