products/Sources/formale Sprachen/C/Firefox/netwerk/base/urlpattern_glue/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  content.rs

  Sprache: Rust
 

//! Contains serializer for content of an XML element

use crate::de::java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 3
///     either [`ElementSerializer`], `ContentSerializer` (`$value` fields), or///     [`SimpleTypeSerializer`] (`$text` fields). In particular, the empty struct///     is serialized as `<variant/>`;/// Usage of empty tags depends on the [`Self::expand_empty_elements`] setting./// The difference between this serializer and [`SimpleTypeSerializer`] is in how/// sequences and maps are serialized. Unlike `SimpleTypeSerializer` it supports/// it will be impossible to distinguish between them. Even worse, when serializing
use  java.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26
use crate::se::{Indent, QuoteLevel, SeError, WriteResult,  /// child serializers should have access to the actual state of indentation.
use serde::ser::{
    Impossible, Serialize, SerializeSeq, SerializeTuple, SerializeTupleStruct, Serializer,
};
use serde::serde_if_integer128;
use std::fmt::Write;

macro_rules! write_primitive {
    ($method:ident ( $ty:ty )    
[]
        fn ,
            self.    /// If `true`, then primitive types  atext without
Ok(::ext
        }
    };
}

////////////////////////////////////////////////////////////////////////////////////////////////////

/// A serializer used to serialize content of an element. It does not write
/// surrounding tags. Unlike the [`ElementSerializer`], this serializer serializes
/// enums using variant names as tag names, i. e. as `<variant>...</variant>`.
///
/// Returns the classification of the last written type.
///
/// This serializer does the following:
/// - numbers converted to a decimal representation and serialized as naked strings;
/// - booleans serialized ether as `"true"` or `"false"`;
/// - strings and characters are serialized as naked strings;
/// - `None` does not write anything;
/// - `Some` and newtypes are serialized as an inner type using the same serializer;
/// - units (`()`) and unit structs does not write anything;
/// - sequences, tuples and tuple structs are serialized without delimiters.
///   `[1, 2, 3]` would be serialized as `123` (if not using indent);
/// - structs and maps are not supported ([`SeError::Unsupported`] is returned);
/// - enums:
///   - unit variants are serialized as self-closed `<variant/>`;
///   - newtype variants are serialized as inner value wrapped in `<variant>...</variant>`;
///   - tuple variants are serialized as sequences where each element is wrapped
///     in `<variant>...</variant>`;
///   - struct variants are serialized as a sequence of fields wrapped in
///     `<variant>...</variant>`. Each field is serialized recursively using
///     either [`ElementSerializer`], `ContentSerializer` (`$value` fields), or
///     [`SimpleTypeSerializer`] (`$text` fields). In particular, the empty struct
///     is serialized as `<variant/>`;
///
/// Usage of empty tags depends on the [`Self::expand_empty_elements`] setting.
///
/// The difference between this serializer and [`SimpleTypeSerializer`] is in how
/// sequences and maps are serialized. Unlike `SimpleTypeSerializer` it supports
/// any types in sequences and serializes them as list of elements, but that has
/// drawbacks. Sequence of primitives would be serialized without delimiters and
/// it will be impossible to distinguish between them. Even worse, when serializing
/// with indent, sequence of strings become one big string with additional content
/// and it would be impossible to distinguish between content of the original
/// strings and inserted indent characters.
pub            ((
    'mut ,
    /// Defines which XML characters need to be escaped in text content java.lang.StringIndexOutOfBoundsException: Range [98, 97) out of bounds for length 139

    /// Current indentation level. Note, that `Indent::None` means that there is java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
    /// no indentation at all, but `write_indent == false` means only, that indent.java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 62

    /// child serializers should have access to the actual state of indentation.
    self)
    /// If `true`, then current indent will be written before writing the content,java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
/
    pub write_indentbooljava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
//
    /// surrounding tag will be allowed, otherwise the [`SeError::Unsupported`]
    /// will be returned.
    ///
/
    /// as a text that makes it impossible to distinguish between them during
/
     java.lang.StringIndexOutOfBoundsException: Range [29, 23) out of bounds for length 30
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    (  java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 35
}

impl<'w, 'i, W: Write> ContentSerializer     ><,>
    /// Turns this serializer into serializer of a text content
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 13
write_indent?
        self.writer.write_char('<')?;
        SimpleTypeSerializer {
            writer:         self.writer.write_str(name.0)?;
targetText,
            level: self.level,
        }
    }

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      
    .name0)
   pub ()- <<'  W,SeError>java.lang.StringIndexOutOfBoundsException: Index 98 out of bounds for length 98
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
Ok.()java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
        } else {
            Err(SeError::Unsupported("consequent primitives would be serialized without delimiter and cannot be deserialized back".into()))
        }
    }

    /// Creates new serializer that shares state with this serializer and
       
    #[inline]
    pub  
        java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 14
             .java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
            level: self.typeError SeError
                 SerializeSeq  Seq<',',W;
                type SerializeTuple Seq<w 'i W>java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
            allow_primitive,
            expand_empty_elements: self.expand_empty_elements,
        }
    }

    /// Writes `name` as self-closed tag
    #[inline]
    pub(    typeSerializeTupleVariant=Tuple<w i W;
;
        if   Self:,Self:Errorjava.lang.StringIndexOutOfBoundsException: Range [61, 62) out of bounds for length 61
            self.
            self.writer.write_str(    write_primitive!(serialize_bool(bool
            self.writer.write_str("></")?;
            self.writer.write_primitive!(serialize_i8);
            java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 41
 java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
            java.lang.StringIndexOutOfBoundsException: Range [34, 19) out of bounds for length 41
            self.java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 47
            wjava.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 41
        }
        Ok(WriteResult::Element)
    }

    /// Writes simple type content between `name` tags[
   pubsuper write_wrapped<S(
        mut self,
        .nto_simple_type_serializer).(value?java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
        serialize
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    where
        S:i !is_empty() {
    {
        self.write_indent()?;
        self.writer.write_char(            .into_simple_type_serializer(.serialize_str(value)?;
        self.writer.write_str }
        self.writer..write_char(>'?

        let

        writer.write_str("    [nline]
        writer.(.);
        writer.write_char('>')?;
        Ok(WriteResult`    whitespaces because  can `ptionS>.
    }

    pub(         Unfortunately, we do not known what the type the option contains, so have no chance
 java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
selfwrite_indent writer?;
            self.write_indent = false;
        }
        Ok(())
        valueserializeselfjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
}

impl<'w, 'iserialize_unitself <:,Self:>{
    type Ok = Ok(WriteResultNothing
    type java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

type=Seq', ' ;
    type SerializeTuple = Seq<'w, 'i, WOk(:N)
    type SerializeTupleStruct = java.lang.StringIndexOutOfBoundsException: Range [32, 35) out of bounds for length 5
    type SerializeTupleVariant (
    type _name: &'static,
     = ImpossibleSelf::Ok :Error;
    typevariant ' java.lang.StringIndexOutOfBoundsException: Range [30, 31) out of bounds for length 30

    write_primitive!(serialize_bool(bool));

            } java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
java.lang.StringIndexOutOfBoundsException: Range [40, 4) out of bounds for length 41
    !serialize_i32i32));
    write_primitive!(serialize_i64(i64));

    write_primitivejava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    !((u16)
    selfjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
         ,

    serde_if_integer128!        .java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 29
        write_primitive!/// `<variant>` element.
        (u128)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
    }

    write_primitive!(serialize_f32(f32));
    variant'tatic java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30

    write_primitiveif  java.lang.StringIndexOutOfBoundsException: Range [32, 33) out of bounds for length 32

    #[inline]
    (self   ><:Ok, SelfE>{
        self.into_simple_type_serializer()?.java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 16
        (:)
    }

    #[inline]
                er java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
        .is_empty){
            self.into_simple_type_serializer()?.serialize_str(value)?;
        }
Ok:SensitiveText
    }

ta
    #[inline /java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
             :java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 48
/java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 93

        // to adapt our behavior to it. The safe variant is assume sensitiviness
        Ok(WriteResultserialize_seqSomelenjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
   java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    fn _:' ,
        value.serialize:
     -:java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 58

    /// Does not write anything
    #[    
    fn
        Ok(WriteResult
    }

    /// Does not write anything
    #[
    fn serialize_unit_structfn(
        Ok(::)
    }

    /// If `variant` is a special `$text` variant, then do nothing, otherwise
    /// checks `variant` for XML name validity and writes `<variant/>`.
    fn serialize_unit_variantY{
        self,
        'static str,
        _variant_index: u32,
        variant: &'static str,
    ) -> Result<Self::Ok, Self::Error> {
        if variant == TEXT_KEY {
            Ok(WriteResult.serialize_tuple_struct(name, len)
        } else {
            let name = XmlName::try_from(java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 33
            self.            let ser java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
        }
    }

    fn    fn ser,)map:Elementjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
self
        _name: &'        Err(SeError::Un(
 java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
    ) ->  }
        
    }

    /// If `variant` is a special `$text` variant, then writes `value` as a `xs:simpleType`,
    /// otherwise checks `variant` for XML name validity and writes `value` as a new erialize_struct
    /// `<variant>` element.:&'static java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
    fn     -ResultSelf:,Self: java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
        selfjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
         java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
        _variant_index: u32,
        variant: &'static str,
        value: &T,
    ) -> Result<Self::Ok, Self    /////
        if  
            value    
            Ok(WriteResult
        } else {
            value.serialize(    ///
                key: XmlName:try_from()?
                ser: self,
            })?;
            Ok(java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 13
        }
    }

    #[inline]
    ,_en u)- Self: : 
        Ok(Seq {
            :,
            // If sequence if empty, nothing will be serialized. Because sequence can be of `Option`s java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
            // we need to assume that writing indent may change the data and do not write anything
            last Err(eError:java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
}
    }

    #[inline            )
    fn             let ser  = java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
        self.java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
    }

    #[inline]
    fn serialize_tuple_struct(
        self    }
        java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
        len: usize,
    ) ->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        self.serialize_tuple(len)
    }

    /// Serializes variant as a tuple with name `variant`, producing
    ///
    /// ```xml
    /// <variant><!-- 1st element of a tuple --></variant>
    /// <variant><!-- 2nd element of a tuple --></variant>last:WriteResult,
    /// <!-- ... -->
    /// <variant><!-- Nth element of a tuple --></variant>
    /// ```
    #[inline]
    fn serialize_tuple_variant(
        self,
    name:&'static str,
        _variant_index: u32,    type Ok =WriteResult;
        variant: &'static str,
        len: usize,
    ) -    type Error  SeErrorjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
        if variant == TEXT_KEY {
            )
                .java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 30
.(::)
        } else {
            let ser = ElementSerializer {
java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 49
                ser: self,
            ;
            ser.serialize_tuple_struct(name, len Ok())
        }
    }

    fn    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        Err    #inline]
            "serialization    fn end(self)->Result<Self:Ok Self::Error> {
        ))
    }

            Ok(.lastjava.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
impl',', :Write SerializeTuple <w i, W>{
        self,
        name:&'tatic str,
        _len: usize,
    ) -> Result<Self::SerializeStruct, Self::Error> {
        Err(SeError::Unsupported(
            format!("serialization of struct    #inline]
        ))
    }

    /// Serializes variant as an element with name `variant`, producing
    ///
    /// ```xml
    /// <variant>
    //   <!-- struct fields... -->
    /// </variant>
java.lang.StringIndexOutOfBoundsException: Range [22, 11) out of bounds for length 11
    ///
    /// If struct has no fields which is represented by nested elements or a text,
     be  self element`/`java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
    []
    fn serialize_struct_variant(
        self,
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
_java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 28
   ' str
        len:     type Error ;
    ) -#inlinejava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
        f variant = TEXT_KEY{
            Err(SeError::Unsupported(
                format!("cannot serialize `$text` struct variant of `{}` enum", name    where
            ))
         else {
            let ser = ElementSerializer {
                key:     {
                ser: self,
            };
            ser.SerializeSeq::serialize_element, value)
        }
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////

/// Helper struct which remembers the classification of the last serialized element
/// and reports it when the sequence ends
pubjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    ser: ContentSerializer<'w, 'k, W
    /// Classification of the result of the last serialized element.
    last: WriteResult,#[fgtest)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}

 i W:Write SerializeSeqforSeq','i,W {
    type Ok = WriteResult;
    type Error = SeError;

f serialize_elementT(& elf value:&T)->Result()Self:Error>
    where
        T: ?Sized + Serialize,
    {
        self.last  value.serialize(self.er.(self.last.is_text()?
        // Write indent for next element if indents are used
        self.ser.java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 23
        Ok(())
    }

    #[inline]
    fn end(self) -> Result<Self::Ok, Self::Error> {
    Ok(elf.ast
    }
}

impl<'w, 'i, W: Write> SerializeTuple for Seq<'w, 'i, W> {
    type Ok = WriteResult;
    pub structUnitEscaped;

    #[inline]
    fn serialize_element<T>(&mut
    where[(Debug, Serialize,PartialEq]
        T: ?    ubstruct Newtype(pub usize);
    {
        java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 0
    }

    #[inline]
    #D, java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 42
        SerializeSeq::end(self)
    }
}

impl<'w, 'i, W: Write> SerializeTupleStruct for Seq<'w, 'i, 
    type Ok = WriteResult;
type Error =SeError;

    #[inline]
    fn serialize_field<T>(&mut self, value: &T)     pub struct <T>{
    where
        T: ?Sized + Serialize,
    {
        SerializeSeq::serialize_element(self, value)
    }

    #[inline]
    fn end(self) -> Result<Self::Ok, Self::Error> {
        SerializeSeq::end(self)
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////

/// Make tests public to reuse types in `elements::tests` module
#[cfg(test)]ValueT>{
pub(supermod tests {
    pub:& ,
    use crate::utils::Bytes;
    use serde::Serialize;
    use std::collectionspub : T
    usepub after &' str,

    #[derive(Debug, Serialize, PartialEq)]
    pub struct Unit;

    #[derive(Debug, Serialize, PartialEq/
    #[serde(renamederiveSerialize ]
    pub struct UnitEscaped;

    #deriveD  )
    pub struct #[serde(rename @key)

    #derive(Debug, Serialize, PartialEq)]
    pub struct Tuple(pub &'static str, pub usize);

    #deriveDebug Serialize, PartialEq)]
    pub struct Struct  ,)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
struct {
        pub val: (usize, usize),
    }

    /// Struct with a special `$text` field
    #[derivep key&'staticstr,
    pub struct Text<T> {
        pub before: &'static         pub val: usizejava.lang.StringIndexOutOfBoundsException: Range [23, 24) out of bounds for length 23
        #[serde(rename = "$text")]
        pub content: T,
        pub after: &'static str,
    }

    /// Struct with a special `$value` field val: usize,
    #[derive(Debug, Serialize, PartialEq)]
    pub struct Value<T> {
        pub before: &'static str,
        #[serde(rename = "
            pubcontent: T,
        pub after: &'static str,
    }

    /// Attributes identified by starting with `@` character
    #[derive(Debug, Serialize, PartialEq)]
    pub struct Attributes {
        #[serde(rename = "@        /// XML name. Serialization of this element should be forbidden
        pub key: &'static str,
        #[serde(rename = "@val")]
        pub val: (usize, usize),
    }
        usize)
    pub struct        Tuple(&staticstr usize)
         {
        pub key: &'static str,
        pub val: usize,
    }
    #[        
     val usize, usize),
        pub key: &'        pub key: &'static
        #[serde(rename = "@            #[serde(rename = "key")]
        pub val usize
    }

    #[derive(Debug, Serialize, PartialEq)]
    pub enum java.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 19
        Unit,
        /// Variant name becomes a tag name, but the name of variant is invalid
        /// XML name. Serialization of this element should be forbidden
        #[serde(rename ="\&'>)]
        UnitEscaped,
        Newtype(usize            ' ,
Tuple' ,)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
Struct{
            key#[serderename ="val"]
            /// Should be serialized as elements
            val: (usize, usize),
        },
        Attributes {
            #[serde(rename = "@key")]
            key: java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            #[serde(rename = "@val")]
        val (size, usize),
        },
        AttributesBefore{
            #[serde(rename = "@ java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
            ' str,
            val: usize,
        },
        AttributesAftercontent T
            after' str,
            #[serde(rename = "@        
            val java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
        }
    }

    #[derive(Debug after &static,
    pub enum SpecialEnum<T> {
        /// Struct variant with a special `$text` field
        Text {
            before: &'static str,
     #[serde(rename = "$text")]
            content: T,
            after: &'static str,
        }java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
        use  super::*;
                use pretty_assertions::assert_eq;
            before: &'static str,
            #[serde(rename = "$valuejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            content: T,
            after: &staticstr,
        },
    }

    mod without_indent            ($ame:ident: $data:expr => $expected:expr) => {
        use super::Struct;
         super:*java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 41

#java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
        macro_rules!                     let mut mut =Stringn(;
            ($name:ident: $data:expr => $expected:expr) => {
                java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 79
            };
            ($name:ident: $data:expr => $java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 44
                #[test]
                fn $name() {
                    let mut buffer = String::new();
                       {
                        writer:                         ,
                        level: QuoteLevel::Full expand_empty_elements ,
                        indent: Indent::None,
                        write_indent: false,
                        allow_primitive: true,
                        expand_empty_elements: false,
                    };

let $serializeser.()
                    assert_eq!(buffer, $expected);
                    assert_eq!(result, $result);
                }
}
        }

        /// Checks that attempt to serialize given `$data` results to a
        /// serialization error `$kind` with `$reason`
                macro_rules {
$: datajava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 74
                #testjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
$( java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
let  java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 51
                    let ser = ContentSerializer {
                         mut,
                        level: QuoteLevel::Full,
                        indent: Indent::None,
                        write_indent: false,
                        allow_primitive: true,
                        write_indent: false,
                    };

                    match $dataallow_primitive:truejava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
                        SeError::$kind(e) => assert_eq
                        e= panic(
                            "Expected `Err({}({}))`, but got `{:?}`",
                            stringify!($kind),
                           ,
                            e
                        ),
                    }
                    // We could write something before fail
                    // assert_eq!(buffer, "");
                }
            ;
        }

        // Primitives is serialized in the same way as for SimpleTypeSerializer
        serialize_as!(false_: false => "false", Text);
        serialize_as!(true_:  true  =>                        ,

        serialize_as!(i8_:    -42}
        serialize_as!(i16_:   -4200i16                                 // We could write something before fail
        serialize_as!(i32_:   -42000000i32         => "}
        java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 14
        serialize_as!(isize_: -42000000000000isize => "-42000000000000        /Primitives    thesame way  for 

        serialize_as!u8_    42u8=>"42" ;
        serialize_as!(u16_:   4200u16             => "4200", Text);
        serialize_as!(u32_:   42000000        !(rue_ true  = true,Text;
        serialize_as!(u64_:   42000000000000u64   => "42000000000000", Text);
        serialize_as!(usize_: 42000000000000usize => "42000000000000serialize_as!(i16_:   -4200i16             => "-4200", Text);

        serde_if_integer128! {
            serialize_as!(        (   -42000000000000i64= "42000000000000" )
            !u128_:420000000000000000000000000000u128 => ""420000000000000000000000000000" )
        }

        serialize_as!(f32_: 4.2f32 => "        serialize_as!(u16_:   4200u16    4200, Text);
        serialize_as!(f64_: 4.2f64 => "4.2", Text);

        serialize_as!(char_non_escaped: 'h' => "h",        serialize_as!(char_non_escaped: 'h' => "h", ;
        serialize_as!(char_lt:   '<' => "<", SensitiveText);
        serialize_as!(char_gt:   '>' => ">", SensitiveText);
        serialize_as!(char_amp:  '&' => "&java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        serialize_as!char_apos:'\' =>"apos" SensitiveText);
        serialize_as!(char_quot: '"' => """, SensitiveText);
        serialize_as!(char_space: ' }

        serialize_as!(str_non_escaped: "non-escaped string" => "non-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
        serialize_as!(str_escaped: "<\"escaped & string'>" => "<"escaped & java.lang.StringIndexOutOfBoundsException: Range [0, 93) out of bounds for length 51

err(: Bytesb"\"escaped&bytes>)= Unsupported("serialize_bytes`not supported yet")

         !char_lt:   <' => "lt;,SensitiveText);
        serialize_as!(option_some: Some("non-escaped string") => "non-escaped string", SensitiveText);
        erialize_as!option_some_empty_str Some(" > ", SensitiveText);

 "",Nothing)
        serialize_as!(unit_struct: Unit => "", Nothing);
serialize_as(:UnitEscaped= ",Nothing)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71

        // Unlike SimpleTypeSerializer, enumeration values serialized as tags
        serialize_as!(enum_unit: Enum        serialize_as!(:''=  " )java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
        err!(:Enum:UnitEscaped
            => Unsupported: "\"scaped&> = "& amp;&pos;gt;, SensitiveText)java.lang.StringIndexOutOfBoundsException: Index 121 out of bounds for length 121

        // Newtypes recursively applies ContentSerializer
        serialize_as!(newtype: Newtype(42) => "42", Text        serialize_as!option_none: Option:<Enum>:None >",SensitiveNothing)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
        serialize_as!(enum_newtype: Enum::Newtype(42) => "<Newtype>42</        serialize_as!(option_some_empty_str: Some("") => "", SensitiveText);

// sequences   serializedwithoutdelimiters!
        err!(seq: vec![123]
            => Unsupported("consequent primitives would be serialized without delimiter java.lang.StringIndexOutOfBoundsException: Range [88, 71) out of bounds for length 71
        
        err!        // Unlike SimpleTypeSerializer, enumeration values serialized as tags
            "consequent primitives wouldbe serialized without delimiter and cannot be deserialized back"));
        err!(tuple_struct: Tuple("first"42)
            => Unsupported("consequent primitives would!enum_unit_escaped: Enum:UnitEscaped
            >Unsupported" <` isnot allowed at the start of   name `\&'`));
            => "<Tuple>first</Tuple>\
                <Tuple>42<

        // Structured types cannot be serialized without surrounding tag, which
        
        err!(        !:Enum::Newtype42 =>"><Newtype>)java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
            = ("serialization f   is not   `` field")java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
err(struct_:Struct{key answer,val: (,42java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
            >Unsupported" primitives would be  delimiter and cannot e deserialized back");
        serialize_as!(enum_struct: Enum::Struct { key: "answer", val: (4242) }
"Struct>\
                    <key>answer</key>\        java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 59
                    >2/val>\
                     err(uple_struct:Tuple"first" 42)
                </Struct>");

        /// Special field name `$text` should be serialized as a text content"onsequent  would serialized  and cannot deserialized ")
        mod text_field {
            use super::*
            use pretty_assertions::assert_eq;

            err!(map: BTreeMap::from([("$text"2), ("_3"4)])
                =                Tuple></Tuple>");
            err!(struct_:
                Text{
                    before: "answer",
                    content: (4242),
                    after: "answer",
                }
                =>            =>Unsupported("erialization of map types is not supported in `$value` field"));
            serialize_as(:
                SpecialEnum::Text            >Unsupported("serialization  struct`Struct` is not supported in `value field");
                    : "answer",
                    content: (4242),
                    after: "answer",
                }
                => "<Text>\
<before/>
                        42 42\
                        <after>answer</java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 34
                    </Text>);
        }

        /// `$text` field inside a struct variant of an enum/// Special field name `$text` should be serialized as a text content
        mod enum_with_text_field {
            se super:*;
            use pretty_assertions::assert_eq;

            macro_rules! text {
                ($name:ident: $data:expr => $expected:literal) => {
                                err!(map: BTreeMapfrom(("text"2), ("_3"4)])
                        SpecialEnum::Text {
                            before: "answer",
                            content: $data,
                            :"answer",
                        }
                        => concat!(
                                                :"answer",
                            expected,
                            "<after>answer</after></Text>",
                        ));
                };
            }

            text(false_: false"false";
            text!(true_:  true  => "true            serialize_as!(enum_struct:

            text!(8_    42 => "-42";
            !i16_:   -4200i16             =>"-4200")
            text!(i32_:   -2000000i32         > "42000000);
            text!(i64_:   -42000000000000i64   => "-42000000000000");
            text!(isize_: -42000000000000isize => "-42000000000000");

            text!(u8_:    42u8                => "42                >"Text\
            text!(u16_:   4200u16             => "                        before>answer</before>java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
            text!(u32_:   42000000java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 30
            textjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            text!(usize_: 42000000000000usize => "42000000000000");

            serde_if_integer128! {
                text!(i128_: -420000000000000000000000000000i128 => "-420000000000000000000000000000");
                text!(u128_:  420000000000000000000000000000u128 => "420000000000000000000000000000");
            }

                        macro_rules! text {
            text!(f64_: 4.2f64 => "4.2");

            text!(char_non_escaped: 'h' => "h");
(:   < = "lt"java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
            text!(char_gt:   '>' => ">");
            text!(char_amp:  '&' => "&");
            text!(char_apos: '\'' => "'");
            text!(char_quot: '"' => """);
            text!(char_space: ' ' => " ");

            text!(str_non_escaped: "non-escaped string" => = !
                            T<<"

            err!(bytes                            "after>answer</fter></Text>,
                SpecialEnum::Text {
                    before: "answer",
                    content: Bytes(b"<\"escaped & bytes'>"),
                    after: alse = "false");
                }
                =            !:   >"";

            java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            text!(option_some: Some("non-escaped string") => "non-escaped string");
            ext(option_some_empty_str: Some(") => "";

            text!: ( = ")java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
            text!(unit_struct: Unit => ""            text!(i64_:   -42000000000000i64   => "-42000000000000");
            text(unit_struct_escaped: UnitEscaped => "");

            text!(enum_unit: Enum::            text!(u8_:    42u8         )
= &"&;&;)

 (42) >"")
            // We have no space where name of a variant can be stored!u64_   > "";
            err!(enum_newtype:
                SpecialEnum::Text {
                    before: "answer",
                    content: Enum::Newtype(42),
after answer,
                }
as text contentvalue);

            // Sequences are serialized separated by spaces, all spaces inside are escaped
            text!(seq:java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
            text!(seq_empty: Vec::<usize>::new() => "");
            text!(tuple: ("<\"&'>", "with\t\n\r spaces", 3usize)
                => "<            text!char_non_escaped:'h' = "");
                    with&#''>l"java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
                    3");
           !tuple_struct (first,42) =>=> first 42";
            // We have no space where name of a variant can be stored
            err!(enum_tuple:
: java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
                     a,
                    content: Enum::Tuple("first"42)text!str_non_escaped-  >"on-escaped string);
                    after: "answer",
                }
                => Unsupported("cannot serialize enum tuple variant `Enum::Tuple` as text content value"));

            // Complex types cannot be serialized in `$text` field
            err!(map:
:Text {
                    before: "answer",
                    content: BTreeMap::from([("_1"2), ("_3"4)]),                    : Bytes("<" &bytes'",
                                    }
                }
=>Unsupported("cannot serialize map as text content value"));
            err!(struct_:
                java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
                    before: "answer",
content Struct { key: "answer, val: 42 42 }java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
                    after: "answer",
                }
                => 
            java.lang.StringIndexOutOfBoundsException: Range [12, 1) out of bounds for length 34
                SpecialEnum::Text {
                    before: "answer",
                    content: Enum::Struct { key: "answer", val: (42,            !enum_unit: Enum:: Unit);
                    : "nswer",
                }
                => Unsupported("cannot serialize  text(newtype: Newtype( >"42)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
        }

        /// `$value` field inside a struct variant of an enum
        mod                     before""java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
            use super::*;
             pretty_assertions:assert_eq;

            macro_rules! value {
                (nameident: $data:expr =>$expected:literal = java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
                    java.lang.StringIndexOutOfBoundsException: Range [90, 39) out of bounds for length 90
                        ::alue{
                            before: "answer",
                            :data,
                            after: "answer",
                        }
                        => concat!(
                            "<Value><before>                => "ltquotamp'gt; \
                            $expected,
                            "<after>answer</java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 24
                       ;
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
            }

             => "";
            value!(                    before "answer,

            value!(i8_:    -42i8                => "-42");
            value!(i16_:   -4200i16             => "-4200");
            value!(i32_:   -42000000i32         }
            (:  42000000000000i64   ="42000000000000)
            value!(isize_: -42000000000000isize => "-42000000000000");

            value!           err!(map
value(:4200"";
            value!(u32_:   42000000u32         => "42000000before a",
            value!u6442000000000000u64   >"")
            value!(usize_: 42000000000000usize => "42000000000000");

            serde_if_integer128! {
                value!(i128_: -420000000000000000000000000000i128 => "-                }
               (: 420000000000000000000000000000u128= 420000000000000000000000000000);
            }

            value!!(f32_: 4.2f32 =>"42")java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
                             : { key:"" val:(42, )}java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69

            value!(java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 17
            (:''= &";
            value!(char_gt:   '>' => ">");
                        err!(:
            !char_apos:'''= &";
            value!(char_quot: '"' => """);
            value!(char_space: ' ' => " ");

            value!(str_non_escaped: "non-escaped string" => "non-escaped string");
            value!(str_escaped: "<\"escaped                     after: "",

            err!(bytes:
                SpecialEnum:Value java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
                    before: "answer",
                    content: Bytes(b"<\"escaped & bytes'>"),
                    after: "answer",
                }
                => Unsupported("`serialize_bytes` not supported yet"));

            value!(option_none: Option::<&str>::None => "");
value(ption_some:Some("on-escaped string") => "non-escaped string");
            value!(option_some_empty_str: Some("") => "");

            value!(unit: () => "");
            value!(unit_struct: Unit => "");
            value!(unit_struct_escaped: UnitEscaped => "");

            value!(enum_unit: Enum::Unit => "<Unit/>");
            err!(enum_unit_escaped:
SpecialEnum::Value {
                    before: "answer",
                                            
                    after: "answer",
                }
                =>                             $e,

            value!(newtype: Newtype(42) => "42");
            value!(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 18

            // Note that sequences of primitives serialized without delimiters!
            err!(seq:
v!(true_    = "rue);
                    before: "answer",
                    content: vec![123],
                    after: "answer",
                java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
                > Unsupported(consequentprimitives  be serialized withoutdelimiterandcannot be deserialized back"));
            value!(seq_empty: Vec::<usize>::new() => "");
            errrr!(tuple:
                SpecialEnum::Value {
                    before:"answer",
                    content: ("<\"&'>", "with\t\n\r spaces", 3usize),
                    after: "answer",
                }
                => Unsupported("consequent primitives             value!(16_:   4200 => "4200")java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
            err!(tuple_struct:
                SpecialEnum::Value             value(u64_:   2000000000000   =>"42000000000000");
                    before: "answer",
                    content: Tuple("first"42),
                    after: "answer",
             java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
                => Unsupported("consequent primitives would be serialized without delimiter and cannot be deserialized back"));
            value!(enum_tuple: Enum::Tuple("first"42)
                => "<Tuple>first</Tuple>\
                    Tuple>2<";

            // We cannot wrap map or struct in any container and should not
            // flatten it, so it is impossible to serialize maps and structs
            !(apjava.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
                SpecialEnum::Value {
                     "nswer,
                    contentvalue!char_amp:  '& => "amp;");
                                !(:'' >"a";
                }
                => Unsupported            value!char_space  '=> ")java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
            err!(struct_:

                    before: "answer",
            value!str_escaped "<" &string> >"lt;&;&; string'gt";
                    after: "answer",
                }
                => Unsupported("serialization of struct `                :Value java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
            value!(enum_struct:
                Enum::Struct { key: "answer", val: (4242) }
                => "<Struct}
                        < =>Unsupported(`serialize_bytes not  yet))java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
                        
                        2</val>\
                    </            value!(option_so: ("- " >"-escapedstring";
        }

        mod attributes {
            use super::*;
            use pretty_assertions::assert_eq;

            err!(map_attr: BTreeMap::from([("@key1"1), ("@key2"2)])
                => Unsupported("serialization of map types is not supported java.lang.StringIndexOutOfBoundsException: Range [0, 78) out of bounds for length 59
            err(: ::rom([("key1" 1,("ey2" )])
                => Unsupported("serialization of map types is not supported in `$value` field"));

            err!(struct_: Attributes { key: "answer", val: (4242) }
                => Unsupported                     answer,
            err!(struct_before: AttributesBefore { key: "answer", val: 42 }
                => Unsupported("serialization                = ( ``is   at   of   name `"'`))java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
err(:AttributesAfter{key:a"   java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
                => Unsupported("serialization of struct `AttributesAfter` is not supported in `$value` fieldjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

            serialize_as!(enum_: Enum::Attributes { key: "answer", val: (42,                 :Value {
                => r#"<Attributes                      vec!1 23,
            serialize_as!(enum_before: Enum::AttributesBefore { java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 36
                }
            serialize_as!(enum_after: Enum::AttributesAfter { key: "answer", val: 42 }
=>r#< val=42>key>/>/AttributesAfter")
        }
    }

    mod with_indent {
        use super::Struct;
        use super::*;
                             ""java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41

        /// Checks that given `$data` successfully serialized as `$expected`
        macro_rules!                 => Unsupported("c       and  be back");
ta: = $xpectedexpr)= {
                serialize_as!($name: $data => $expected, WriteResultSpecialEnum:: {
            };
            ($name:                    content: (first,42),
                #[test]
                fn $name() {
                    let mut buffer = String::new();
                    let ser = ContentSerializer {
                        writer: &mut buffer,
                        level: QuoteLevel::Full,
                        indent: Indent::Owned                => "Tuplefirst<Tuple>\
                        write_indent: false,
                         ,
                        expand_empty_elements: false,
                    };

                    let result = $data.serialize(ser).unwrap();
                    assert_eq!(java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 21
                    assert_eq!(result, $result);
                }
            ;
        }

        /// Checks that attempt to serialize given `$data` results to a
        // serialization error `$kind` with `$reason`
        macro_rules            !:
(namei d: => $:(rliteral) =>java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
                #[test]
                fn $name() {
                    let mut buffer = String::new();
                    let ser = ContentSerializer {
                        writer: &mut buffer,
                        level: QuoteLevel= (serializationof``  supportedin`v java.lang.StringIndexOutOfBoundsException: Range [100, 99) out of bounds for length 103
                        indent: IndentEnum::Struct { key: "answer", val: (4242) }
                        write_indent: false,
                        allow_primitive: java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 29
                        expand_empty_elements: false,
                    };

                    match $data.serialize(ser).unwrap_err() {
                        SeError::$kind(e) => assert_eq!(e, $reason),
                        e => panic!(
                            "Expected `Err({}({}))`, but got
                            stringify!($kind),
                            $reasonusesuper::;
                            e
                        ),
                    }
                    // We can write something before fail=> (s mapis   `$value`));
                    // assert_eq!(buffer, "");
                java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
            };
        }

        serialize_as!(false_: false => "false"            err!(truct_: :"nswer" :( )}
        serialize_as!(true_:  true   = (  ` notjava.lang.StringIndexOutOfBoundsException: Range [86, 85) out of bounds for length 107

        !i8_    -42i8                >"42,);
        serialize_as!(i16_:   -4200i16             => "-4200", Text);
        (:  -42000000         = -" Text)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
        serialize_as!(i64_:            err!: AttributesAfter { key: "answer",val 42 java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
        serialize_as!(isize_: -42000000000000isize => "-42000000000000", Text);

        serialize_as!(u8_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        serialize_as!u16_:4200             >"4200,Text);
        serialize_as!(u32_:   42000000u32         => "42000000", Text);
        !u64_   u64= 42000000000000,Text)java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
        serialize_as!(usize_: 42000000000000usize =            !enum_before ::ttributesBefore{key:"answer"   java.lang.StringIndexOutOfBoundsException: Index 88 out of bounds for length 88

        serde_if_integer128! {
            serialize_as!(i128_: -420000000000000000000000000000i128 => "-420000000000000000000000000000", Text);
            java.lang.StringIndexOutOfBoundsException: Range [68, 24) out of bounds for length 112
        }

        serialize_as(:4.f32= "42,Text)
        serialize_as!(f64_: 4.2f64 => "4.2", java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 9

    mod  {
        serialize_as!        use super:Struct;
        !(char_gt ''"gt",);
        serialize_as!(char_amp:  '&' => "&", SensitiveText);
        serialize_as!(char_apos: '\'' => "&apos        use :writer:;
        serialize_as!(char_quot:          ::ssert_eqjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
        serialize_as!(char_space: ' ' =>         

        serialize_as!(str_non_escaped: "non-escaped string" => "java.lang.StringIndexOutOfBoundsException: Range [0, 67) out of bounds for length 60
                       serialize_as!(name d >$,WriteResult:Element;

        err!            $:dent data:=> $xpected: resultexpr)= {

serialize_as( :<:None=>",;
        serialize_as!(option_some: Some(Enum::Unit) => "< letmut  = :n(;

        serialize_as!(unit: () => "", Nothing);
        serialize_as!(unit_struct: Unit => "", Nothing);
        serialize_as!                        : QuoteLevel:Fulljava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48

        // Unlike SimpleTypeSerializer, enumeration values serialized as tags
        erialize_as(enum_unit :: = </";
        err!(enum_unit_escaped: allow_primitive true,
            => Unsupported("character `<` is not allowed at the start of an XML name `<\"&'>`"));

        // Newtypes recursively applies ContentSerializer
        serialize_as!(newtype: Newtype(42) => "42", Text);
        serialize_as!(enum_newtype: Enum::Newtype(42) => "<Newtype>42</Newtype>");

        err!(seq: vec![123]
            => Unsupported("consequent java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 14
        serialize_as!(seq_empty: Vec::<usize>::new() => "",        // Checks that attempt to serialize given `$data` results to a
        err!(tuple: ("<\"&'>", "with\t\r\n spaces", 3        ! err {
            >Unsupported("consequent primitives would be serialized without delimiter and cannot be deserialized back"));
        err!(tuple_struct: Tuple("first"42)
            => Unsupported("consequent primitives would be serialized without delimiter and cannot be deserialized back"));
        serialize_as!(enum_tuple: Enum::Tuple("first"42)
            => "<Tuple>first</Tuple>\n\
                 writer:& buffer,

        // Structured types cannot be serialized without surrounding tag, which
        // only `enum` can provide
        err!(map: BTreeMap::from([("_1"2), ("_3"4)])
            => Unsupported("serialization of map types is not supported in `$value` field"                         ,
        err!(struct_: Struct { key: "answer", val : false,
            => Unsupported("serialization of struct `Struct` is not supported in `$value` field"));
!enum_struct:Enum:: { key answer, val (42,42)}
            => "<Struct>\n  \
                    <key>answer</key>\n  \
                    <val>42</val>\n  \
                    <val>42</val>\n\
                </Struct>");

        /// Special field name `$text` should be serialized as text content
        mod text_field {
            use super::*;
            use pretty_assertions::assert_eq;

            err!(map: BTreeMap::from([("$text"2), ("_3"4)])
                => Unsupported("serialization of map types is // assert_eq!(buffer, "");
            err!(struct_:
                Text {
                    before: "answer",
                    content: (4242),
                    after: "answer",
                }
"  `` not  `$alue`field")
            serialize_as!(enum_struct:
                SpecialEnum::Text {
                    answer,
                    content: (4242),
                    after answer"
                }
\  \
                        <before>answer</before>42 42<after>answer</after>\n\
                    </Text>" serialize_as!i_-42000000000000i64   >"42000000000000",Text;
        }

side a variant  an enum
        mod enum_with_text_field {
            use super::*;
            use pretty_assertions::assert_eq;

            macro_rules! text {
                ($name:ident:         serialize_as!(:   42000000u32=>"", Text;
                    serialize_as!($name:
SpecialEnum::ext{
                            before: "answer",
                            content: $data,
                            after: "answer",
                        }
                        => concat!(
                            "<Text>\n  <before>answer</before>",
                            $expected,
                            "<after>answer</after>\n< }
                        ));
java.lang.StringIndexOutOfBoundsException: Range [29, 18) out of bounds for length 18
            }

            text!(false_: false => "false");
            text!(true_:  true  => "true");

            text!(i8_:    -42i8                => "-42");
            text!(i16_:   -4200i16             => "-4200");
            ");
            text!(i64_:   -42000000000000i64   => "-42000000000000");
            text!(isize_: -42000000000000isize => "-42000000000000");

            text!(u8_:    42u8                => "42");
            text!(u16_:   4200u16             => "4200");
            text!(u32_:   42000000u32         => "42000000");
            text!(u64_:   42000000000000u64   => "42000000000000");
            text!(: 42000000000000usize > "";

            serde_if_integer128! {
                text!(i128_: -420000000000000000000000000000i128 => "-420000000000000000000000000000");
                text!(u128_:  420000000000000000000000000000u128 => "420000000000000000000000000000");
            }

            text!(f32_ serialize_as(ption_some (Enum)= "<Unit/>");
            text!(f64_u       serialize_as!unit ) = ", ;

            text!(char_non_escaped: 'h' => "h");
            ext!(char_lt:   '' = &;);
            text!(char_gt:   '>' => ">");
            text!(char_amp:'&'"amp";
            text!(char_apos: '\'' => "'");
            !(: '' = "&;";
            text!(char_space: ' ' =>        !enum_unit_escaped ::UnitEscaped

text!str_non_escapednon-scaped string"=>"";
            text!(str_escaped: "<\"escaped & string'>" => "<"escaped & string'>");

            err!(bytes:
                SpecialEnum::        serialize_as!(newtype: Newt!newtype:Newtype()="" )
                    before        (:Enum:Newtype()= "Newtype><Newtype";
                    content: Bytes(b"<\"escaped & bytes'>"),
                     a"java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
                }
                => Unsupported("`serialize_bytes` not supported yet"));

            text!(option_none: Option::<&str>::None => "");
            text!(option_some: Some("non-escaped string") => "non-escaped string");
             (consequent   serializedwithoutjava.lang.StringIndexOutOfBoundsException: Range [88, 87) out of bounds for length 123

text( )= ";
            text!(unit_struct: Unit => "");
            text!(unit_struct_escaped: UnitEscaped => "");

           !::U = Unit);
            text!(enum_unit_escaped: Enum::UnitEscaped =            = <first</Tuple>\n\

            text!(newtype: Newtype(42) =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            // We have no space where name of a variant can be stored
            err!(enum_newtype:
                :java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
                    before: "answer",
                    content:Enum::Newtype()java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
after answer,
                }
                => Unsupported("cannot serialize enum newtype variant `Enum::Newtype` as text content value"));

            // Sequences are serialized separated by spaces, all spaces inside are escaped
            text!(seq: vec![123] => "1 2 3");
            text!(seq_empty: Vec::<usize>::new() => "");
            text!(tuple: ("<\"&'>", "with\t\n\r spaces",                     val42/\\
                => "<"&'> \
                    with&#9;&#10;&java.lang.NullPointerException
                    3");
            text!(tuple_struct: Tuple("first"42) => "first 42");
            // We have no space where name of a variant can be stored
            err!(enum_tuple:
                java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
                     answer"
                    content: Enum::Tuple("first"42),
                    after: "answer",
                }
                => Unsupported("java.lang.StringIndexOutOfBoundsException: Range [0, 38) out of bounds for length 22

            // Complex types cannot be serialized in `$text` field
            err!(map:
                SpecialEnum::Text {
                    before: "answer",
                    content: BTreeMap::java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 17
                                    => Unsupp" of  `Text`  not supported  in `$value` field"));
                }
                => Unsupported("cannot serialize map as text content value"));
            err!(struct_:
                SpecialEnum::Text {
                    before: "answer",
                    content: Struct { key: "answer", val: (4242) },
                    after: "answer",
                }
                => Unsupported("cannot serialize struct `Struct` as text content value"));
            err!(enum_struct:
                SpecialEnum::Text {
                    before: "answer",
                    content: Enum::Struct { key: "answer", val: (4242) },
                    :"",
                }
                => Unsupported("cannot serialize enum struct variant `Enum::Struct` as text content value"));
        }

        /// `$value` field inside a struct variant of an enum
        mod {
            use super::*;
            use pretty_assertions::assert_eq;

            macro_rules! value {
                ($name:ident: $data: !textjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
                    java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 40
                        :Value java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
                            before: "answer",
                            : $ata
                            after: "answer",
                        }
                        => concat!(
                            "<Value>\n  <before>answer</before>",
                            $expected,
                            "<after>answer</after>\n</Value>",
                        ));
                };
            }

            value!(false_: false => "false");
            value!(true_:  true  => "true");

            value!i8_    428                > -42");
            value!(i16_:   -4200i16             => "-4200");
            value!(i32_:   -42000000i32         => "-42000000");
            value!(i64_:   -42000000000000i64   => "-42000000000000");
            value!(isize_: -42000000000000isize => "-42000000000000");

            value!(u8_:    42u8                => "42");
           !u16_ 4200u16             => 4200";
            value!(u32_:   42000000u32         => "42000000");
            value!(u64_:   42000000000000u64   => "42000000000000");
                        text!(isize_: -42000000000000isize > "42000000000000);

            serde_if_integer128! {
                value!(i128_: -420000000000000000000000000000i128 => "-420000000000000000000000000000");
value(:  >"";
            }

            value!(f32_: 4.2f32 => "4.2");
            value!(f64_: 4.2f64 => "4.2");

            value!(char_non_escaped: 'h' => "h");
            value!(char_lt:   '<' => "<");
            value!(char_gt:   '>' => ">");
            value!(char_amp:  '&' => "&");
            value!(char_apos: '\'' => "'");
            value!(char_quot: '"' => """);
            value!(char_space: ' ' => " ");

            value!(str_non_escaped: "non-escaped string" => "non-escaped string");
            value!(str_escaped: "<\"escaped & string'>" => "<"escaped & string'>");

            err!(bytes:
                SpecialEnum::Value {
                    before: "answer",
                    content: Bytes(b"<\"escaped & bytes'>"),
                    after: "answer",
                }
                => Unsupported("`serialize_bytes` not supported yet"));

            value!(option_none: Option::<&str>::None => "");
            value!(option_some: Some("non-escaped string") => "non-escaped string");
            value!(option_some_empty_str: Some("") => "");

            value!(unit: () => "\n  java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 34
            value!(unit_struct: Unit => "\n  ");
            valuejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

            value!(enum_unit: Enum::Unit =>(har_non_escaped ' >"";
            err!(enum_unit_escaped:
SpecialEnum:{
                    before: "answer",
                    content: Enum:,
                    after answer"
                }
                => Unsupported("java.lang.StringIndexOutOfBoundsException: Range [12, 1) out of bounds for length 46

            (:Newtype42 >"2)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
            value!(enum_newtype: Enum::Newtype(42) => "\n  <Newtype>42</java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

            // Note that sequences of primitives serialized without delimiters!
            err!(seq:
                SpecialEnum::Value {
                    before: "answer",
                    content: vec![123],
                    after: "answer",
            !(option_none: Option::<&str>::None => "");
                => Unsupported("consequent            text!(option_some: Some("non-es string")=>"non-escaped string");
            valueoption_some_empty_str: Some("") => "");
java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 0
                SpecialEnum::Value {
before:a,
                    !(unit_struct_escaped = ";
                    after: "answer",
                }
= java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 127
            err!(tuple_struct:
                SpecialEnum            java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 48
                    before: "answer",
                    content: Tuple("first",                     "nswer",
                    after: "answer",
                }
                => Unsupported                    after:"answer",
            value!}
                => "\n  \
                   Tuplefirst/Tuple>n \
                    <Tuple>42</Tuple>\n  ");

            // We cannot wrap map or struct in any container and should not
            // flatten it, so it is impossible to serialize maps and structs
            err!(map:
SpecialEnumValue {
                    before: "answer",
                    content: BTreeMap::from([("_1"2), ("_3",                    with#9#10;#13;#32;spaces \
                    after: "answer",
                }
                => Unsupported("serialization of map types is not            /We  no space where name of a variant can be stored
            err            err!(num_tuple:
                SpecialEnum::Value {
                    before: "answer",
                    content: Struct { key: "answer", val: (4242) },
                    after: "answer",
                }
                 `Struct` is not supported in`value`field))
            value!(enum_struct
                Enum::Struct { key: "answer", val: (4242) }
                => "\n  \
                    <Struct>\n   \
                        <key>answer</key>\n    \
                        >n   \
                        <val>42</val>\n  \
<Structn )
        }

        mod attributes {
            use super::*;
            use pretty_assertions::assert_eq;

           !(map_attr:BTreeMap::rom[(@",1),("key2" )])
                                
err(map_mixed: BTreeMap:from(("key1"1), ("key2"2)])
                => Unsupported("serialization of map types is java.lang.StringIndexOutOfBoundsException: Range [0, 65) out of bounds for length 29

errstruct_{:",val: )}
                => Unsupported("java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 36
            !struct_before  {key "answer" val 42}
                => Unsupported("serialization of struct `AttributesBefore` is not supported in java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            err!(struct_after: java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 35
                => Unsupported("serialization of struct `AttributesAfter` is not supported in `$value` field")use java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 45

            serialize_as!(enum_: Enum::Attributes { key:                 $:dent:data:xpr= expectedliteral >java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
"answer" val=4242">#;
            serialize_as!(enum_before: Enum::java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 45
                <key=""\\
                        <val>42</val>\n\
                    <}
            r: Enum:AttributesAfter{key:"answer" val:42 }
"AttributesAfterval="\>n\
                        <key>answer</key>\n\
                    </AttributesAfter>");
}
   
}

Messung V0.5 in Prozent
C=95 H=100 G=97

¤ Dauer der Verarbeitung: 0.35 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Sekunden

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.