Parse KML without converting to UTF-8 and back to bytes

This commit is contained in:
Alexander Krotov
2020-02-14 22:17:50 +03:00
committed by Floris Bruynooghe
parent 04bb6997a2
commit 672fe2dfd7

View File

@@ -64,11 +64,10 @@ impl Kml {
Default::default()
}
pub fn parse(context: &Context, content: &[u8]) -> Result<Self, Error> {
ensure!(content.len() <= 1024 * 1024, "kml-file is too large");
pub fn parse(context: &Context, to_parse: &[u8]) -> Result<Self, Error> {
ensure!(to_parse.len() <= 1024 * 1024, "kml-file is too large");
let to_parse = String::from_utf8_lossy(content);
let mut reader = quick_xml::Reader::from_str(&to_parse);
let mut reader = quick_xml::Reader::from_reader(to_parse);
reader.trim_text(true);
let mut kml = Kml::new();