diff --git a/content/tokio/tutorial/channels.md b/content/tokio/tutorial/channels.md index f7a64503..231895a8 100644 --- a/content/tokio/tutorial/channels.md +++ b/content/tokio/tutorial/channels.md @@ -271,7 +271,7 @@ let t2 = tokio::spawn(async move { tx2.send(cmd).await.unwrap(); }); # } -```` +``` At the bottom of the `main` function, we `.await` the join handles to ensure the commands fully complete before the process exits. diff --git a/content/tokio/tutorial/framing.md b/content/tokio/tutorial/framing.md index 406a78ac..369f7c2d 100644 --- a/content/tokio/tutorial/framing.md +++ b/content/tokio/tutorial/framing.md @@ -180,7 +180,7 @@ pub async fn read_frame(&mut self) Let's break this down. The `read_frame` method operates in a loop. First, `self.parse_frame()` is called. This will attempt to parse a redis frame from `self.buffer`. If there is enough data to parse a frame, the frame is returned -to the caller of `read_frame()`.Otherwise, we attempt to read more data from the +to the caller of `read_frame()`. Otherwise, we attempt to read more data from the socket into the buffer. After reading more data, `parse_frame()` is called again. This time, if enough data has been received, parsing may succeed. @@ -464,9 +464,7 @@ async fn write_frame(&mut self, frame: &Frame) Frame::Array(_val) => unimplemented!(), } - self.stream.flush().await; - - Ok(()) + self.stream.flush().await } # async fn write_decimal(&mut self, val: u64) -> io::Result<()> { unimplemented!() } # } @@ -488,7 +486,7 @@ in the buffer to the socket. Another alternative would be to **not** call `flush()` in `write_frame()`. Instead, provide a `flush()` function on `Connection`. This would allow the -caller to write queue multiple small frames in the write buffer then write them +caller to queue multiple small frames in the write buffer then write them all to the socket with one `write` syscall. Doing this complicates the `Connection` API. Simplicity is one of Mini-Redis' goals, so we decided to include the `flush().await` call in `fn write_frame()`. diff --git a/content/tokio/tutorial/spawning.md b/content/tokio/tutorial/spawning.md index 8d2a3a94..8dd17da7 100644 --- a/content/tokio/tutorial/spawning.md +++ b/content/tokio/tutorial/spawning.md @@ -225,7 +225,7 @@ note: function requires argument type to outlive `'static` | 7 | task::spawn(async { | _________________^ -8 | | println!("Here's a vector: {:?}", v); +8 | | println!("Here's a vec: {:?}", v); 9 | | }); | |_____^ help: to force the async block to take ownership of `v` (and any other