From 34af5fc53011910ce6f2618bd66c3f53a00efb56 Mon Sep 17 00:00:00 2001
From: Matt Johnston <matt@ucc.asn.au>
Date: Sun, 6 Nov 2022 15:36:29 +0800
Subject: [PATCH] Some tidying and comments for todo!()

---
 embassy/demos/std/src/main.rs |  2 +-
 embassy/src/embassy_sunset.rs | 17 +++++------------
 src/channel.rs                |  2 +-
 src/cliauth.rs                |  2 +-
 src/packets.rs                |  2 +-
 src/runner.rs                 |  2 +-
 6 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/embassy/demos/std/src/main.rs b/embassy/demos/std/src/main.rs
index cab788b..96841eb 100644
--- a/embassy/demos/std/src/main.rs
+++ b/embassy/demos/std/src/main.rs
@@ -150,7 +150,7 @@ impl DemoServer {
 
 impl ServBehaviour for DemoServer {
     fn hostkeys(&mut self) -> BhResult<&[SignKey]> {
-        todo!()
+        todo!("hostkeys()")
         // Ok(&self.keys)
     }
 
diff --git a/embassy/src/embassy_sunset.rs b/embassy/src/embassy_sunset.rs
index 33eff10..2646ec2 100644
--- a/embassy/src/embassy_sunset.rs
+++ b/embassy/src/embassy_sunset.rs
@@ -27,7 +27,6 @@ pub struct EmbassySunset<'a> {
     pub(crate) inner: Mutex<NoopRawMutex, Inner<'a>>,
 
     progress_notify: Signal<NoopRawMutex, ()>,
-    lock_waker: WakerRegistration,
 }
 
 impl<'a> EmbassySunset<'a> {
@@ -44,7 +43,6 @@ impl<'a> EmbassySunset<'a> {
         Self {
             inner,
             progress_notify,
-            lock_waker: WakerRegistration::new(),
          }
     }
 
@@ -94,14 +92,13 @@ impl<'a> EmbassySunset<'a> {
 
     pub async fn read(&self, buf: &mut [u8]) -> Result<usize> {
         poll_fn(|cx| {
-
-            trace!("read locking");
+            // Attempt to lock .inner
             let i = self.inner.lock();
             pin_mut!(i);
             let r = match i.poll(cx) {
                 Poll::Ready(mut inner) => {
-                    warn!("read lock ready");
                     match inner.runner.output(buf) {
+                        // no output ready
                         Ok(0) => {
                             inner.runner.set_output_waker(cx.waker());
                             Poll::Pending
@@ -111,12 +108,10 @@ impl<'a> EmbassySunset<'a> {
                     }
                 }
                 Poll::Pending => {
-                    trace!("read lock pending");
+                    // .inner lock is busy
                     Poll::Pending
                 }
             };
-            trace!("read result {r:?}");
-
             r
         })
         .await
@@ -124,12 +119,10 @@ impl<'a> EmbassySunset<'a> {
 
     pub async fn write(&self, buf: &[u8]) -> Result<usize> {
         poll_fn(|cx| {
-            trace!("write locking");
             let i = self.inner.lock();
             pin_mut!(i);
             let r = match i.poll(cx) {
                 Poll::Ready(mut inner) => {
-                    warn!("write lock ready");
                     if inner.runner.ready_input() {
                         match inner.runner.input(buf) {
                             Ok(0) => {
@@ -144,14 +137,14 @@ impl<'a> EmbassySunset<'a> {
                     }
                 }
                 Poll::Pending => {
-                    trace!("write lock pending");
+                    // .inner lock is busy
                     Poll::Pending
                 }
             };
             if r.is_ready() {
+                // wake up .progress() to handle the input
                 self.progress_notify.signal(())
             }
-            trace!("write result {r:?}");
             r
         })
         .await
diff --git a/src/channel.rs b/src/channel.rs
index 175a2e1..60fc9a4 100644
--- a/src/channel.rs
+++ b/src/channel.rs
@@ -411,7 +411,7 @@ impl Channels {
                 trace!("channel success, TODO");
             }
             Packet::ChannelFailure(_p) => {
-                todo!();
+                todo!("ChannelFailure");
             }
             _ => Error::bug_msg("unreachable")?,
         };
diff --git a/src/cliauth.rs b/src/cliauth.rs
index f9cdc8e..211e88a 100644
--- a/src/cliauth.rs
+++ b/src/cliauth.rs
@@ -184,7 +184,7 @@ impl CliAuth {
 
         match auth60 {
             Userauth60::PkOk(pkok) => self.auth_pkok(pkok, sess_id, parse_ctx, s),
-            _ => todo!(),
+            Userauth60::PwChangeReq(_req) => todo!("pwchange"),
         }
     }
 
diff --git a/src/packets.rs b/src/packets.rs
index 1069873..ec6e081 100644
--- a/src/packets.rs
+++ b/src/packets.rs
@@ -349,7 +349,7 @@ impl <'a> From<&'a OwnedSig> for Signature<'a> {
     fn from(s: &'a OwnedSig) -> Self {
         match s {
             OwnedSig::Ed25519(e) => Signature::Ed25519(Ed25519Sig { sig: BinString(e) }),
-            OwnedSig::RSA256 => todo!(),
+            OwnedSig::RSA256 => todo!("sig from rsa"),
         }
     }
 }
diff --git a/src/runner.rs b/src/runner.rs
index 5543ba4..526c2bc 100644
--- a/src/runner.rs
+++ b/src/runner.rs
@@ -267,7 +267,7 @@ impl<'a> Runner<'a> {
     }
 
     pub fn term_window_change(&self, _chan: u32, _wc: packets::WinChange) -> Result<()> {
-        todo!();
+        todo!("term_window_change()");
         // self.conn.channels.term_window_change(chan, wc)
     }
 
-- 
GitLab