diff --git a/README.md b/README.md index 2901f82..8b673ed 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ distributed actors. It has three dependencies: - serde - serde_json - serde_repr - -For a simple example, see the [echo](https://git.kittencollective.com/nebkor/nebkor-maelstrom/src/branch/main/examples/echo.rs) example: + +Here's a simple and complete example that implements the single node [echo](https://fly.io/dist-sys/1/) challenge: ``` rust use nebkor_maelstrom::{Body, Message, Node, Runner}; @@ -55,7 +55,7 @@ much away. Create a struct and implement `nebkor_maelstrom::Node` for it, which involves a single method, `handle(&mut self, &Runner, Message)`. This method is passed a `Runner` which contains methods like -`send`, `reply`, and `rpc`. +`send()`, `reply()`, and `rpc()`. In your main function, instantiate that struct and pass that into `Runner::new()` to get a Runner. The `run()` method takes an optional callback that will be run when the `init` Message is @@ -83,6 +83,6 @@ diving into its source from your IDE or browser. ## Acknowledgments -I straight-up stole the design of the IO/network system from -[Maelbreaker](https://github.com/rafibayer/maelbreaker/), which allowed me to get a working RPC -call. Thanks! And thanks to Nicole for nudging me to publish this. +I straight-up stole the initial design of the IO/network system from +[Maelbreaker](https://github.com/rafibayer/maelbreaker/), which allowed me to get working RPC +calls; thanks! And thanks to Nicole for nudging me to publish this. diff --git a/src/kv.rs b/src/kv.rs index 22f8284..18a3ef4 100644 --- a/src/kv.rs +++ b/src/kv.rs @@ -35,7 +35,8 @@ impl Kv { /// let kv = Kv::seq(); /// let result = kv.read(&runner, "MY_KEY"); /// // if "MY_KEY" had previously been written into the store, then the Result will be `Ok` - /// // and the body will always be `Some(Value)`. + /// // and the body will always be `Some(Value)`; otherwise, it will be an `Err`, probably + /// // an `ErrorCode::Definite(DefiniteError::KeyNotFound)`. /// assert!(result.is_ok() && result.unwrap().is_some()); /// ``` pub fn read(&self, runner: &Runner, key: &str) -> RpcResult {