usecrate::Stream; use pin_project_lite::pin_project; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncBufRead, Lines};
pin_project! { /// A wrapper around [`tokio::io::Lines`] that implements [`Stream`]. /// /// [`tokio::io::Lines`]: struct@tokio::io::Lines /// [`Stream`]: trait@crate::Stream #[derive(Debug)] #[cfg_attr(docsrs, doc(cfg(feature = "io-util")))] pubstruct LinesStream<R> { #[pin]
inner: Lines<R>,
}
}
impl<R> LinesStream<R> { /// Create a new `LinesStream`. pubfn new(lines: Lines<R>) -> Self { Self { inner: lines }
}
/// Get back the inner `Lines`. pubfn into_inner(self) -> Lines<R> { self.inner
}
/// Obtain a pinned reference to the inner `Lines<R>`. #[allow(clippy::wrong_self_convention)] // https://github.com/rust-lang/rust-clippy/issues/4546 pubfn as_pin_mut(self: Pin<&mutSelf>) -> Pin<&mut Lines<R>> { self.project().inner
}
}
impl<R: AsyncBufRead> Stream for LinesStream<R> { type Item = io::Result<String>;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.