remove broken stream implementation
This commit is contained in:
parent
1d831b4c4e
commit
4f0691de7d
|
@ -97,9 +97,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.30"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
|
||||
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
|
@ -107,9 +107,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.30"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
|
||||
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
|
@ -124,15 +124,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.30"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
|
||||
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.30"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
||||
checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -141,21 +141,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.30"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
|
||||
checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.30"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
|
||||
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.30"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
|
||||
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
|
@ -292,6 +292,7 @@ dependencies = [
|
|||
"async-recursion",
|
||||
"circular",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"nom",
|
||||
"tokio",
|
||||
"tracing",
|
||||
|
|
|
@ -9,6 +9,7 @@ edition = "2021"
|
|||
async-recursion = "1.1.1"
|
||||
circular = { version = "0.3.0", path = "../circular" }
|
||||
futures = "0.3.30"
|
||||
futures-util = { version = "0.3.31", features = ["sink"] }
|
||||
nom = "7.1.3"
|
||||
tokio = { version = "1.36.0", features = ["io-util", "net", "io-std", "full"] }
|
||||
tracing = "0.1.41"
|
||||
|
|
|
@ -39,11 +39,7 @@ pub enum Error {
|
|||
ExtraData(String),
|
||||
UndeclaredNamespace(String),
|
||||
IncorrectName(Name),
|
||||
UnexpectedAttribute(Name),
|
||||
DeserializeError(String),
|
||||
UnexpectedNumberOfContents(usize),
|
||||
UnexpectedContent(Content),
|
||||
UnexpectedElement(Name),
|
||||
Deserialize(DeserializeError),
|
||||
}
|
||||
|
||||
|
|
|
@ -721,26 +721,10 @@ impl<R> Reader<R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<R: AsyncRead + Unpin> Stream for Reader<R> {
|
||||
type Item = Result<Content>;
|
||||
|
||||
fn poll_next(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Option<Self::Item>> {
|
||||
let mut e = self;
|
||||
let mut pinned = pin!(e.read_content());
|
||||
pinned.as_mut().poll(cx).map(|result| Some(result))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test {
|
||||
use futures::{sink::Buffer, StreamExt};
|
||||
use tokio::io::AsyncRead;
|
||||
|
||||
use crate::element::Element;
|
||||
|
||||
use super::Reader;
|
||||
|
||||
pub struct MockAsyncReader<'s> {
|
||||
|
@ -855,25 +839,4 @@ pub(crate) mod test {
|
|||
let element = reader.read_element().await.unwrap();
|
||||
println!("{:#?}", element);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_element_stream() {
|
||||
let mock = MockAsyncReader::new(TEST_DOC);
|
||||
let mut reader = Reader::new(mock);
|
||||
let element = reader.read_start_tag().await.unwrap();
|
||||
println!("start element: {:#?}", element);
|
||||
let mut content_count = 0;
|
||||
loop {
|
||||
if let Some(content) = reader.next().await {
|
||||
match content {
|
||||
Ok(content) => {
|
||||
content_count += 1;
|
||||
println!("content {}: {:#?}", content_count, content)
|
||||
}
|
||||
Err(_) => break,
|
||||
}
|
||||
}
|
||||
}
|
||||
reader.read_end_tag().await.unwrap()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
use std::{collections::HashSet, pin::pin, str::FromStr};
|
||||
use std::{
|
||||
collections::{HashSet, VecDeque},
|
||||
pin::pin,
|
||||
str::FromStr,
|
||||
task::Poll,
|
||||
};
|
||||
|
||||
use async_recursion::async_recursion;
|
||||
use futures::Sink;
|
||||
use circular::Buffer;
|
||||
use futures::{Future, FutureExt, Sink, SinkExt};
|
||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
|
||||
use crate::{
|
||||
|
|
Loading…
Reference in New Issue