I have something similar to the tokio connect example with a method that accepts a sink:
pub async fn connect(
addr: &SocketAddr,
mut stdin: impl Stream<Item = Result<Request, io::Error>> + Unpin,
mut stdout: impl Sink<Response, Error = io::Error> + Unpin,
) -> Result<(), Box<dyn Error>> {
Is there a standard/easy way to adapt a function to a sink for printing and/or transformation?
eg. something like:
connect(.., .., sink::from_function(|r| match r {
Ok(response) => println!("received a response: {:?}", response),
Err(e) => println!("error! {:?}", e);
})
.await;