diff options
author | 2024-12-06 06:33:10 +0000 | |
---|---|---|
committer | 2024-12-06 06:33:10 +0000 | |
commit | 4f0691de7d8d00e6c58da58186e511425f7470ed (patch) | |
tree | 7ef46d1fa3f588f16d1b68624d47e9f9deea9af5 /src | |
parent | 1d831b4c4e730a7a7a4556e6c71aecc88d73d9ee (diff) | |
download | peanuts-4f0691de7d8d00e6c58da58186e511425f7470ed.tar.gz peanuts-4f0691de7d8d00e6c58da58186e511425f7470ed.tar.bz2 peanuts-4f0691de7d8d00e6c58da58186e511425f7470ed.zip |
remove broken stream implementation
Diffstat (limited to 'src')
-rw-r--r-- | src/error.rs | 4 | ||||
-rw-r--r-- | src/reader.rs | 37 | ||||
-rw-r--r-- | src/writer.rs | 10 |
3 files changed, 8 insertions, 43 deletions
diff --git a/src/error.rs b/src/error.rs index 0cac59b..fff59d4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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), } diff --git a/src/reader.rs b/src/reader.rs index d2de170..074ab99 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -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() - } } diff --git a/src/writer.rs b/src/writer.rs index 5f9f3fd..013d37b 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -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::{ |