diff options
| author | 2025-04-12 09:24:19 +0100 | |
|---|---|---|
| committer | 2025-04-12 09:24:19 +0100 | |
| commit | 3d575ec2a4440e7e4597761eab907d63ef91175e (patch) | |
| tree | 19edf8ad38300304f6bd2f0d81660173b5fee611 /examples | |
| parent | 92f4fd88295cb39bf865e10b0a28cc36acb5276a (diff) | |
| download | peanuts-3d575ec2a4440e7e4597761eab907d63ef91175e.tar.gz peanuts-3d575ec2a4440e7e4597761eab907d63ef91175e.tar.bz2 peanuts-3d575ec2a4440e7e4597761eab907d63ef91175e.zip | |
feat: move tokio features to dev-dependencies to allow wasm supportwasm
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/example.rs | 95 | 
1 files changed, 95 insertions, 0 deletions
| diff --git a/examples/example.rs b/examples/example.rs new file mode 100644 index 0000000..580652e --- /dev/null +++ b/examples/example.rs @@ -0,0 +1,95 @@ +use peanuts::xml::composers::Composer; +use peanuts::xml::parsers::Parser; +use peanuts::xml::Document; + +#[tokio::main] +async fn main() { +    let (rest, document) = Document::parse( +        "<?xml version='1.0' encoding='UTF-8'?> + +   <xs:schema +       xmlns:xs='http://www.w3.org/2001/XMLSchema' +       targetNamespace='http://etherx.jabber.org/streams' +       xmlns='http://etherx.jabber.org/streams' +       elementFormDefault='unqualified'> + +     <xs:import namespace='jabber:client'/> +     <xs:import namespace='jabber:server'/> +     <xs:import namespace='urn:ietf:params:xml:ns:xmpp-sasl'/> +     <xs:import namespace='urn:ietf:params:xml:ns:xmpp-streams'/> +     <xs:import namespace='urn:ietf:params:xml:ns:xmpp-tls'/> + +     <xs:element name='stream'> +       <xs:complexType> +         <xs:sequence xmlns:client='jabber:client' +                      xmlns:server='jabber:server'> +           <xs:element ref='features' +                       minOccurs='0' +                       maxOccurs='1'/> +           <xs:any namespace='urn:ietf:params:xml:ns:xmpp-tls' +                   minOccurs='0' +                   maxOccurs='1'/> +           <xs:any namespace='urn:ietf:params:xml:ns:xmpp-sasl' +                   minOccurs='0' +                   maxOccurs='1'/> +           <xs:any namespace='##other' +                   minOccurs='0' +                   maxOccurs='unbounded' +                   processContents='lax'/> +           <xs:choice minOccurs='0' maxOccurs='1'> +             <xs:choice minOccurs='0' maxOccurs='unbounded'> +               <xs:element ref='client:message'/> +               <xs:element ref='client:presence'/> +               <xs:element ref='client:iq'/> +             </xs:choice> +             <xs:choice minOccurs='0' maxOccurs='unbounded'> +               <xs:element ref='server:message'/> +               <xs:element ref='server:presence'/> +               <xs:element ref='server:iq'/> +             </xs:choice> +           </xs:choice> +           <xs:element ref='error' minOccurs='0' maxOccurs='1'/> +         </xs:sequence> +         <xs:attribute name='from' type='xs:string' use='optional'/> +         <xs:attribute name='id' type='xs:string' use='optional'/> +         <xs:attribute name='to' type='xs:string' use='optional'/> +         <xs:attribute name='version' type='xs:decimal' use='optional'/> +         <xs:attribute ref='xml:lang' use='optional'/> +         <xs:anyAttribute namespace='##other' processContents='lax'/> +       </xs:complexType> +     </xs:element> + +     <xs:element name='features'> +       <xs:complexType> +         <xs:sequence> +           <xs:any namespace='##other' +                   minOccurs='0' +                   maxOccurs='unbounded' +                   processContents='lax'/> +         </xs:sequence> +       </xs:complexType> +     </xs:element> + +     <xs:element name='error'> +       <xs:complexType> +         <xs:sequence  xmlns:err='urn:ietf:params:xml:ns:xmpp-streams'> +           <xs:group   ref='err:streamErrorGroup'/> +           <xs:element ref='err:text' +                       minOccurs='0' +                       maxOccurs='1'/> +           <xs:any     namespace='##other' +                       minOccurs='0' +                       maxOccurs='1' +                       processContents='lax'/> +         </xs:sequence> +       </xs:complexType> +     </xs:element> + +   </xs:schema>asdf +", +    ) +    .unwrap(); +    println!("{:#?}{}", document, rest); +    let mut stdout = tokio::io::stdout(); +    document.write(&mut stdout).await.unwrap(); +} | 
