@@ -54,6 +54,9 @@ use attributes::{Attribute, Attributes};
54
54
///
55
55
/// In well-formed XML it could contain a Byte-Order-Mark (BOM). If this event
56
56
/// contains something else except BOM, the XML should be considered ill-formed.
57
+ ///
58
+ /// This is a reader-only event. If you need to write a text before the first tag,
59
+ /// use the [`BytesText`] event.
57
60
#[ derive( Debug , Clone , Eq , PartialEq ) ]
58
61
pub struct BytesStartText < ' a > {
59
62
content : BytesText < ' a > ,
@@ -142,7 +145,7 @@ impl<'a> BytesStart<'a> {
142
145
///
143
146
/// # Warning
144
147
///
145
- /// `name` is not checked to be a valid name
148
+ /// `name` must be a valid name.
146
149
#[ inline]
147
150
pub fn new < C : Into < Cow < ' a , str > > > ( name : C ) -> Self {
148
151
let buf = str_cow_to_bytes ( name) ;
@@ -156,7 +159,9 @@ impl<'a> BytesStart<'a> {
156
159
///
157
160
/// # Warning
158
161
///
159
- /// `&content[..name_len]` is not checked to be a valid name
162
+ /// `&content[..name_len]` must be a valid name, and the remainder of `content`
163
+ /// must be correctly-formed attributes. Neither are checked, it is possible
164
+ /// to generate invalid XML if `content` or `name_len` are incorrect.
160
165
#[ inline]
161
166
pub fn from_content < C : Into < Cow < ' a , str > > > ( content : C , name_len : usize ) -> Self {
162
167
BytesStart {
@@ -236,7 +241,7 @@ impl<'a> BytesStart<'a> {
236
241
///
237
242
/// # Warning
238
243
///
239
- /// `name` is not checked to be a valid name
244
+ /// `name` must be a valid name.
240
245
pub fn set_name ( & mut self , name : & [ u8 ] ) -> & mut BytesStart < ' a > {
241
246
let bytes = self . buf . to_mut ( ) ;
242
247
bytes. splice ( ..self . name_len , name. iter ( ) . cloned ( ) ) ;
@@ -604,7 +609,11 @@ impl<'a> BytesEnd<'a> {
604
609
BytesEnd { name }
605
610
}
606
611
607
- /// Creates a new `BytesEnd` borrowing a slice
612
+ /// Creates a new `BytesEnd` borrowing a slice.
613
+ ///
614
+ /// # Warning
615
+ ///
616
+ /// `name` must be a valid name.
608
617
#[ inline]
609
618
pub fn new < C : Into < Cow < ' a , str > > > ( name : C ) -> Self {
610
619
Self :: wrap ( str_cow_to_bytes ( name) )
@@ -812,7 +821,11 @@ impl<'a> BytesCData<'a> {
812
821
}
813
822
}
814
823
815
- /// Creates a new `BytesCData` from a string
824
+ /// Creates a new `BytesCData` from a string.
825
+ ///
826
+ /// # Warning
827
+ ///
828
+ /// `content` must not contain the `]]>` sequence.
816
829
#[ inline]
817
830
pub fn new < C : Into < Cow < ' a , str > > > ( content : C ) -> Self {
818
831
Self :: wrap ( str_cow_to_bytes ( content) , Decoder :: utf8 ( ) )
0 commit comments