xml

Macro xml 

Source
xml!() { /* proc-macro */ }
Expand description

Derives Serialization Logic Via Custom DSL Templating

§Borrow Syntax

// you are only allowed one lifetime if you are borrowing
struct MyStruct<'a> {
    field: &'a str,
}

xml! {
    // the keyword ref tells the macro you are borrowing
    ref MyStruct;
     
    // define your namespaces here
    @ns {
        myns = "uri:myns",
    }

    myns:Element attr=(self.field) {
        // parens allow you to write any expression
        (self.field)
    }
}

§Owned Syntax


struct MyStruct {
    owned: String,
}

xml! {
    // the use keyword means you aren't borrowing data
    use MyStruct;

    // define your namespaces here
    @ns {
        myns = "uri:myns",    
    }

    myns:Element {
        (self.owned)
    }
}