use std::{ ffi::OsStr, path::{Component, PathBuf}, }; use tokio::sync::mpsc::Receiver; pub struct W(pub T); pub struct ReceiverIterator { receiver: Receiver, } impl Iterator for ReceiverIterator { type Item = T; fn next(&mut self) -> Option { self.receiver.blocking_recv() } } impl IntoIterator for W> { type Item = T; type IntoIter = ReceiverIterator; fn into_iter(self) -> Self::IntoIter { Self::IntoIter { receiver: self.0 } } } impl From> for String { fn from(value: W) -> Self { value.0.display().to_string() } } impl From> for String { fn from(value: W<&PathBuf>) -> Self { value.0.display().to_string() } } impl From> for String { fn from(value: W<&OsStr>) -> Self { value .0 .to_str() .expect("Failed to get String from OsStr") .to_string() } } impl From>> for String { fn from(value: W) -> Self { Self::from(W(value.0.as_os_str())) } }