diff --git a/hptp-send/src/main.rs b/hptp-send/src/main.rs index 8264977..b957ac3 100644 --- a/hptp-send/src/main.rs +++ b/hptp-send/src/main.rs @@ -225,11 +225,6 @@ where Timer, } - enum Action { - Continue, - Quit, - } - let mut src = SegmentSource::new(inp); let in_flight = 66; @@ -252,31 +247,22 @@ where } ); - let act = match evt { + match evt { Evt::Timer => { let delay_ms = (1000 / in_flight) as u64; deadline += Duration::from_millis(delay_ms); - match src.get_segment().await { - Some((seg_idx, payload)) => { - log.send_data(seg_idx as usize, payload.len()).await; - to_send.push(UpMsg::Data { - seg_idx, - payload: payload.clone(), - }); - Action::Continue - } - None => Action::Quit, + if let Some((seg_idx, payload)) = src.get_segment().await { + log.send_data(seg_idx as usize, payload.len()).await; + to_send.push(UpMsg::Data { + seg_idx, + payload: payload.clone(), + }); } } Evt::Recv(DownMsg::Ack { idxs }) => { log.debug_msg(format!("got {} acks", idxs.len())).await; src.ack(&idxs); - if src.is_file_completed() { - Action::Quit - } else { - Action::Continue - } } }; @@ -288,9 +274,8 @@ where } } - match act { - Action::Continue => (), - Action::Quit => break, + if src.is_file_completed() { + break } }