From ad1b8ccb318cdd3209fd8122a07dd7d546471081 Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Wed, 16 Jul 2025 14:25:36 -0700 Subject: [PATCH] rename 'promises' to 'futures' for rpc returns --- .rustfmt.toml | 2 +- Cargo.toml | 4 ++-- src/kv.rs | 2 +- src/lib.rs | 13 +++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index 4c8d0e1..8feb93e 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,4 +1,4 @@ imports_granularity = "Crate" group_imports = "StdExternalCrate" wrap_comments = true -edition = "2021" +edition = "2024" diff --git a/Cargo.toml b/Cargo.toml index cf159a4..1345176 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "nebkor-maelstrom" -edition = "2021" -version = "1.0.1" +edition = "2024" +version = "1.1.0" license-file = "LICENSE.md" readme = "README.md" description = "An easy-to-use and synchronous client for creating Maelstrom distributed clients." diff --git a/src/kv.rs b/src/kv.rs index 0cce779..22f8284 100644 --- a/src/kv.rs +++ b/src/kv.rs @@ -1,4 +1,4 @@ -use crate::{check_err, mk_payload, Body, RpcResult, Runner, Value}; +use crate::{Body, RpcResult, Runner, Value, check_err, mk_payload}; /// A convenient way to do RPC with Maelstrom's KV services. #[derive(Debug, Default, Clone)] diff --git a/src/lib.rs b/src/lib.rs index 9052b51..4fcd203 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,9 +2,9 @@ use std::{ collections::HashMap, io::{BufRead, Write}, sync::{ - atomic::{AtomicU64, Ordering}, - mpsc::{channel, Receiver, Sender}, Arc, Mutex, OnceLock, + atomic::{AtomicU64, Ordering}, + mpsc::{Receiver, Sender, channel}, }, thread::{self}, }; @@ -18,7 +18,7 @@ pub mod kv; pub type NodeyNodeFace = Arc>; pub type OnInit = Box; -pub type RpcPromise = Receiver; +pub type RpcFuture = Receiver; pub type RpcResult = std::result::Result, ErrorCode>; pub trait Node { @@ -57,6 +57,7 @@ impl Runner { /// /// ```no_run /// use nebkor_maelstrom::{Body, Message, Node, Runner}; + /// /// struct Foo; /// impl Node for Foo {fn handle(&mut self, _runner: &Runner, _msg: Message) { /* empty impl */ }} /// @@ -126,13 +127,13 @@ impl Runner { /// Returns a Receiver that will receive the reply from the /// request. - pub fn rpc(&self, dest: &str, body: Body) -> RpcPromise { + pub fn rpc(&self, dest: &str, body: Body) -> RpcFuture { let msg = self.mk_msg(dest, body); let (tx, rx) = channel(); { let msg_id = msg.body.msg_id; - let mut g = self.promises.lock().unwrap(); - g.insert(msg_id, tx); + let mut promises = self.promises.lock().unwrap(); + promises.insert(msg_id, tx); } self.outbound_tx.get().unwrap().send(msg).unwrap(); rx