@@ -2648,9 +2648,22 @@ where
2648
2648
}
2649
2649
2650
2650
impl < ' de > Deserializer < ' de , SliceReader < ' de > > {
2651
- /// Create new deserializer that will borrow data from the specified string
2651
+ /// Create new deserializer that will borrow data from the specified string.
2652
+ ///
2653
+ /// Deserializer created with this method will not resolve custom entities.
2652
2654
#[ allow( clippy:: should_implement_trait) ]
2653
2655
pub fn from_str ( source : & ' de str ) -> Self {
2656
+ Self :: from_str_with_resolver ( source, NoEntityResolver )
2657
+ }
2658
+ }
2659
+
2660
+ impl < ' de , E > Deserializer < ' de , SliceReader < ' de > , E >
2661
+ where
2662
+ E : EntityResolver ,
2663
+ {
2664
+ /// Create new deserializer that will borrow data from the specified string
2665
+ /// and use specified entity resolver.
2666
+ pub fn from_str_with_resolver ( source : & ' de str , entity_resolver : E ) -> Self {
2654
2667
let mut reader = Reader :: from_str ( source) ;
2655
2668
reader. expand_empty_elements ( true ) ;
2656
2669
@@ -2659,7 +2672,7 @@ impl<'de> Deserializer<'de, SliceReader<'de>> {
2659
2672
reader,
2660
2673
start_trimmer : StartTrimmer :: default ( ) ,
2661
2674
} ,
2662
- NoEntityResolver ,
2675
+ entity_resolver ,
2663
2676
)
2664
2677
}
2665
2678
}
@@ -2669,9 +2682,13 @@ where
2669
2682
R : BufRead ,
2670
2683
{
2671
2684
/// Create new deserializer that will copy data from the specified reader
2672
- /// into internal buffer. If you already have a string use [`Self::from_str`]
2673
- /// instead, because it will borrow instead of copy. If you have `&[u8]` which
2674
- /// is known to represent UTF-8, you can decode it first before using [`from_str`].
2685
+ /// into internal buffer.
2686
+ ///
2687
+ /// If you already have a string use [`Self::from_str`] instead, because it
2688
+ /// will borrow instead of copy. If you have `&[u8]` which is known to represent
2689
+ /// UTF-8, you can decode it first before using [`from_str`].
2690
+ ///
2691
+ /// Deserializer created with this method will not resolve custom entities.
2675
2692
pub fn from_reader ( reader : R ) -> Self {
2676
2693
Self :: with_resolver ( reader, NoEntityResolver )
2677
2694
}
@@ -2683,9 +2700,11 @@ where
2683
2700
E : EntityResolver ,
2684
2701
{
2685
2702
/// Create new deserializer that will copy data from the specified reader
2686
- /// into internal buffer. If you already have a string use [`Self::from_str`]
2687
- /// instead, because it will borrow instead of copy. If you have `&[u8]` which
2688
- /// is known to represent UTF-8, you can decode it first before using [`from_str`].
2703
+ /// into internal buffer and use specified entity resolver.
2704
+ ///
2705
+ /// If you already have a string use [`Self::from_str`] instead, because it
2706
+ /// will borrow instead of copy. If you have `&[u8]` which is known to represent
2707
+ /// UTF-8, you can decode it first before using [`from_str`].
2689
2708
pub fn with_resolver ( reader : R , entity_resolver : E ) -> Self {
2690
2709
let mut reader = Reader :: from_reader ( reader) ;
2691
2710
reader. expand_empty_elements ( true ) ;
0 commit comments