questions: add QuestionsConverterAsyncForStream
This commit is contained in:
@@ -224,6 +224,24 @@ pub mod convert_async {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait QuestionsConverterAsyncForStream<T>
|
||||
where
|
||||
T: Stream<Item = (String, Result<SourceQuestionsBatch, serde_json::Error>)>
|
||||
+ std::marker::Unpin,
|
||||
{
|
||||
fn converter(&mut self) -> QuestionsConverterAsync<&mut T>;
|
||||
}
|
||||
|
||||
impl<T> QuestionsConverterAsyncForStream<T> for T
|
||||
where
|
||||
T: Stream<Item = (String, Result<SourceQuestionsBatch, serde_json::Error>)>
|
||||
+ std::marker::Unpin,
|
||||
{
|
||||
fn converter(&mut self) -> QuestionsConverterAsync<&mut T> {
|
||||
QuestionsConverterAsync::from(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> QuestionsConverterAsync<T>
|
||||
where
|
||||
T: Stream<Item = (String, Result<SourceQuestionsBatch, serde_json::Error>)>
|
||||
@@ -267,7 +285,7 @@ pub mod convert_async {
|
||||
});
|
||||
|
||||
pin_mut!(source);
|
||||
let converter = QuestionsConverterAsync::from(source);
|
||||
let converter = source.converter();
|
||||
let converter = converter.convert();
|
||||
let converted: Vec<_> = converter.collect().await;
|
||||
assert_yaml_snapshot!(converted, @r#"
|
||||
@@ -292,7 +310,7 @@ pub mod convert_async {
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "convert_async")]
|
||||
pub use convert_async::QuestionsConverterAsync;
|
||||
pub use convert_async::{QuestionsConverterAsync, QuestionsConverterAsyncForStream};
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
Reference in New Issue
Block a user