Skip to content

Commit ae458cb

Browse files
Mingundralley
andcommitted
Remove excessive BufRead constraint
Co-authored-by: Daniel Alley <[email protected]>
1 parent 5e6d045 commit ae458cb

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/events/attributes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::reader::{is_whitespace, Reader};
99
use crate::utils::{write_byte_string, write_cow_string, Bytes};
1010
use std::fmt::{self, Debug, Display, Formatter};
1111
use std::iter::FusedIterator;
12-
use std::{borrow::Cow, collections::HashMap, io::BufRead, ops::Range};
12+
use std::{borrow::Cow, collections::HashMap, ops::Range};
1313

1414
/// A struct representing a key/value XML attribute.
1515
///
@@ -81,7 +81,7 @@ impl<'a> Attribute<'a> {
8181
///
8282
/// [`unescaped_value()`]: #method.unescaped_value
8383
/// [`Reader::decode()`]: ../../reader/struct.Reader.html#method.decode
84-
pub fn unescape_and_decode_value<B: BufRead>(&self, reader: &Reader<B>) -> XmlResult<String> {
84+
pub fn unescape_and_decode_value<B>(&self, reader: &Reader<B>) -> XmlResult<String> {
8585
self.do_unescape_and_decode_value(reader, None)
8686
}
8787

@@ -99,7 +99,7 @@ impl<'a> Attribute<'a> {
9999
/// # Pre-condition
100100
///
101101
/// The keys and values of `custom_entities`, if any, must be valid UTF-8.
102-
pub fn unescape_and_decode_value_with_custom_entities<B: BufRead>(
102+
pub fn unescape_and_decode_value_with_custom_entities<B>(
103103
&self,
104104
reader: &Reader<B>,
105105
custom_entities: &HashMap<Vec<u8>, Vec<u8>>,
@@ -108,7 +108,7 @@ impl<'a> Attribute<'a> {
108108
}
109109

110110
/// The keys and values of `custom_entities`, if any, must be valid UTF-8.
111-
fn do_unescape_and_decode_value<B: BufRead>(
111+
fn do_unescape_and_decode_value<B>(
112112
&self,
113113
reader: &Reader<B>,
114114
custom_entities: Option<&HashMap<Vec<u8>, Vec<u8>>>,

src/events/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use encoding_rs::Encoding;
3939
use std::borrow::Cow;
4040
use std::collections::HashMap;
4141
use std::fmt::{self, Debug, Formatter};
42-
use std::io::BufRead;
4342
use std::ops::Deref;
4443
use std::str::from_utf8;
4544

@@ -755,7 +754,7 @@ impl<'a> BytesText<'a> {
755754
/// it might be wiser to manually use
756755
/// 1. BytesText::unescaped()
757756
/// 2. Reader::decode(...)
758-
pub fn unescape_and_decode<B: BufRead>(&self, reader: &Reader<B>) -> Result<String> {
757+
pub fn unescape_and_decode<B>(&self, reader: &Reader<B>) -> Result<String> {
759758
self.do_unescape_and_decode_with_custom_entities(reader, None)
760759
}
761760

@@ -769,15 +768,15 @@ impl<'a> BytesText<'a> {
769768
/// # Pre-condition
770769
///
771770
/// The keys and values of `custom_entities`, if any, must be valid UTF-8.
772-
pub fn unescape_and_decode_with_custom_entities<B: BufRead>(
771+
pub fn unescape_and_decode_with_custom_entities<B>(
773772
&self,
774773
reader: &Reader<B>,
775774
custom_entities: &HashMap<Vec<u8>, Vec<u8>>,
776775
) -> Result<String> {
777776
self.do_unescape_and_decode_with_custom_entities(reader, Some(custom_entities))
778777
}
779778

780-
fn do_unescape_and_decode_with_custom_entities<B: BufRead>(
779+
fn do_unescape_and_decode_with_custom_entities<B>(
781780
&self,
782781
reader: &Reader<B>,
783782
custom_entities: Option<&HashMap<Vec<u8>, Vec<u8>>>,

src/reader.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl EncodingRef {
107107

108108
/// A low level encoding-agnostic XML event reader.
109109
///
110-
/// Consumes a `BufRead` and streams XML `Event`s.
110+
/// Consumes bytes and streams XML [`Event`]s.
111111
///
112112
/// # Examples
113113
///
@@ -144,7 +144,7 @@ impl EncodingRef {
144144
/// }
145145
/// ```
146146
#[derive(Clone)]
147-
pub struct Reader<R: BufRead> {
147+
pub struct Reader<R> {
148148
/// reader
149149
pub(crate) reader: R,
150150
/// current buffer position, useful for debugging errors
@@ -198,8 +198,8 @@ pub struct Reader<R: BufRead> {
198198
}
199199

200200
/// Builder methods
201-
impl<R: BufRead> Reader<R> {
202-
/// Creates a `Reader` that reads from a reader implementing `BufRead`.
201+
impl<R> Reader<R> {
202+
/// Creates a `Reader` that reads from a given reader.
203203
pub fn from_reader(reader: R) -> Self {
204204
Self {
205205
reader,
@@ -323,7 +323,7 @@ impl<R: BufRead> Reader<R> {
323323
}
324324

325325
/// Getters
326-
impl<R: BufRead> Reader<R> {
326+
impl<R> Reader<R> {
327327
/// Consumes `Reader` returning the underlying reader
328328
///
329329
/// Can be used to compute line and column of a parsing error position
@@ -761,7 +761,7 @@ impl<R: BufRead> Reader<R> {
761761
}
762762

763763
/// Private methods
764-
impl<R: BufRead> Reader<R> {
764+
impl<R> Reader<R> {
765765
/// Read text into the given buffer, and return an event that borrows from
766766
/// either that buffer or from the input itself, based on the type of the
767767
/// reader.

0 commit comments

Comments
 (0)