Ok::<_,io::Error>(())
});
- let stream_for_tx = ipif.stdout.take().unwrap();
+ let max_outstanding = ic.max_requests_outstanding
+ .try_into().unwrap_or(usize::MAX);
+
+ let tx_stream = ipif.stdout.take().unwrap();
+ let mut tx_stream = tokio::io::BufReader::new(tx_stream).split(SLIP_ESC);
let stream_for_rx = ipif.stdin .take().unwrap();
-// let txbuf = VecDeque::new();
-/*
+ let mut reqs = Vec::with_capacity(max_outstanding);
+
async {
loop {
select! {
- rx = stream_for_rx
- */
- throw!(anyhow!("arrgh"));
+ packet = tx_stream.next_segment(),
+ if reqs.len() < max_outstanding => {
+ let packet = packet.context("read from ipif")?;
+ reqs.push(());
+ // xxx make new request
+ }
+ }
+ }
+ }.await
}
#[tokio::main]
// There is NO WARRANTY.
pub use std::collections::{BTreeSet, HashMap};
+pub use std::convert::TryInto;
pub use std::cmp::{min, max};
pub use std::fs;
pub use std::fmt::{self, Debug, Display};
pub use log::{debug, info, error};
pub use structopt::StructOpt;
pub use tokio::io::AsyncBufReadExt;
+pub use tokio::select;
pub use tokio::task;
pub use tokio::time::Duration;
pub use void::{self, Void, ResultVoidExt, ResultVoidErrExt};
pub use anyhow::Error as AE;
pub use ErrorKind as EK;
+pub const SLIP_END: u8 = 0o300;
+pub const SLIP_ESC: u8 = 0o333;
+pub const SLIP_ESC_END: u8 = 0o334;
+pub const SLIP_ESC_ESC: u8 = 0o335;
+
pub fn default<T:Default>() -> T { Default::default() }