Optimizations and stuff idk
This commit is contained in:
parent
1d8fac0bd4
commit
1b9d744414
|
@ -188,7 +188,7 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
|||
|
||||
[[package]]
|
||||
name = "holocal"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"quick-xml",
|
||||
"reqwest",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "holocal"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
authors = ["blank X <theblankx@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -82,14 +82,14 @@ fn main() {
|
|||
loop {
|
||||
match reader.read_event(&mut buf) {
|
||||
Ok(Event::Start(ref e)) => {
|
||||
match String::from_utf8(e.name().to_vec()).unwrap().as_str() {
|
||||
"item" => {
|
||||
match e.name() {
|
||||
b"item" => {
|
||||
is_inside_item = true;
|
||||
title = None;
|
||||
url = None;
|
||||
},
|
||||
"title" => is_inside_title = true,
|
||||
"description" => is_inside_description = true,
|
||||
b"title" => is_inside_title = true,
|
||||
b"description" => is_inside_description = true,
|
||||
_ => ()
|
||||
};
|
||||
},
|
||||
|
@ -106,9 +106,9 @@ fn main() {
|
|||
loop {
|
||||
match description_reader.read_event(&mut description_buf) {
|
||||
Ok(Event::Empty(ref e)) => {
|
||||
if String::from_utf8(e.name().to_vec()).unwrap().as_str() == "img" {
|
||||
if e.name() == b"img" {
|
||||
url = Some(e.attributes()
|
||||
.find(|attribute| String::from_utf8(attribute.as_ref().unwrap().key.to_vec()).unwrap().as_str() == "src")
|
||||
.find(|attribute| attribute.as_ref().unwrap().key == b"src")
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.unescape_and_decode_value(&description_reader)
|
||||
|
@ -123,20 +123,20 @@ fn main() {
|
|||
}
|
||||
},
|
||||
Ok(Event::End(ref e)) => {
|
||||
match String::from_utf8(e.name().to_vec()).unwrap().as_str() {
|
||||
"item" => {
|
||||
match e.name() {
|
||||
b"item" => {
|
||||
is_inside_item = false;
|
||||
if title.is_some() && url.is_some() {
|
||||
break;
|
||||
}
|
||||
},
|
||||
"description" => {
|
||||
b"description" => {
|
||||
is_inside_description = false;
|
||||
if title.is_some() && url.is_some() {
|
||||
break;
|
||||
}
|
||||
},
|
||||
"title" => is_inside_title = false,
|
||||
b"title" => is_inside_title = false,
|
||||
_ => ()
|
||||
};
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue