horacimacias
I'm trying to use this crate to parse SIP headers but I'm having a bit of a hard time finding how to actually go from a String or &str into a header, for example From, To. Is there some code I can look at in order to do this?
#46 · closed · 3 comments
I'm trying to use this crate to parse SIP headers but I'm having a bit of a hard time finding how to actually go from a String or &str into a header, for example From, To. Is there some code I can look at in order to do this?
I am not sure if it's the best way but the way I do it is like this ```rust let message = String::from_utf8_lossy(&slice); // this converts Vec<u8> into a string SipMessage::try_from(message.to_string()) // this gives you a Result<SipMessage, rsip::Error> ```
thanks, I'll give this a try. I was actually looking at parsing specific headers (e.g. parsing a String that I know represents a From), but I may end up parsing the whole message instead.
I am quite certain you can do the same thing with individual typed headers as well. I think try_from is implemented for &str for most