Closed yxdxx closed 7 years ago
Hey!
I glad to see that people use this crate, though I doubt it's the right solution for sending xml.
structure
is really good for writing fixed-size buffers, but you want a variable size buffer.
If you still think it could work for you, it could be useful if you upload your hole program or describe better what's the desired output.
Using 's' is the right thing to do if you want to pad your buffer with zeros, but it obviously won't play well with xml, which is a text format.
thank you for your reply... I have write a python code with module struct . it works. if possible, you can give a version of rust code. that will be nice of you.. the xml1 does't seem to display.. I put the attachment as xml content. CreateVMDT_066_01.txt
xml1 = """<?xml version="1.0" encoding="utf-8" standalone="yes"?>
You create a format string at runtime, but it's not supported by this crate (and probably will never be). Rust is a static typed language. Therefore it's not possible to process the format string at runtime without sacrifying the type safety you get (pack gets the right types as parameters, and unpack returns the right types). Processing the format string at runtime is a feature that should be considered, but I've yet to think of a good way to do it. If the interface won't be easy, it will miss the purpose of this crate.
Since you're trying to parse xml, I'd really want you to try serde: https://github.com/RReverser/serde-xml-rs
thank you very much. you are really nice person. I will try to understand the language more deep..^_^,also try to use serde.
Good luck :)
I was writing a program send telegram with TCPSTREAM . send an XML file with an head of the length of the XML characters. =s.pack(lengthstring.as_bytes(),contentbuff).unwrap();
turns out an error:
buffer size in format: 3, actual size: 4", I wanna to padding the left with 0000, how can I do with it .seems > does't work . if I use s, no error ,but the telegram seems still not correct in the head.
also how can I replace with 716. the length of the XML . everytime the length will change.
let s = structure!(">4S716s"); let buffsend:Vec