tweak the docs a bit

This commit is contained in:
Joe Ardent 2025-07-16 14:49:38 -07:00
parent ad1b8ccb31
commit 067a03b918
2 changed files with 8 additions and 7 deletions

View file

@ -8,7 +8,7 @@ distributed actors. It has three dependencies:
- serde_json - serde_json
- serde_repr - 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 ``` rust
use nebkor_maelstrom::{Body, Message, Node, Runner}; 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, 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 `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 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 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 ## Acknowledgments
I straight-up stole the design of the IO/network system from I straight-up stole the initial design of the IO/network system from
[Maelbreaker](https://github.com/rafibayer/maelbreaker/), which allowed me to get a working RPC [Maelbreaker](https://github.com/rafibayer/maelbreaker/), which allowed me to get working RPC
call. Thanks! And thanks to Nicole for nudging me to publish this. calls; thanks! And thanks to Nicole for nudging me to publish this.

View file

@ -35,7 +35,8 @@ impl Kv {
/// let kv = Kv::seq(); /// let kv = Kv::seq();
/// let result = kv.read(&runner, "MY_KEY"); /// let result = kv.read(&runner, "MY_KEY");
/// // if "MY_KEY" had previously been written into the store, then the Result will be `Ok` /// // 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()); /// assert!(result.is_ok() && result.unwrap().is_some());
/// ``` /// ```
pub fn read(&self, runner: &Runner, key: &str) -> RpcResult { pub fn read(&self, runner: &Runner, key: &str) -> RpcResult {