Browse Source

draft meta parser

master
yggverse 2 months ago
parent
commit
4cdfaa2d6b
  1. 45
      src/browser/main/tab/page/mod.rs

45
src/browser/main/tab/page/mod.rs

@ -10,11 +10,12 @@ use gtk::{
prelude::{BoxExt, IOStreamExt, InputStreamExtManual, OutputStreamExtManual, SocketClientExt}, prelude::{BoxExt, IOStreamExt, InputStreamExtManual, OutputStreamExtManual, SocketClientExt},
Box, Orientation, Box, Orientation,
}; };
use std::sync::Arc;
pub struct Page { pub struct Page {
widget: Box, widget: Box,
navigation: Navigation, navigation: Navigation,
content: Content, content: Arc<Content>,
} }
impl Page { impl Page {
@ -76,23 +77,33 @@ impl Page {
vec![0; 0xfffff], // 1Mb @TODO vec![0; 0xfffff], // 1Mb @TODO
Priority::DEFAULT, Priority::DEFAULT,
Some(&Cancellable::new()), Some(&Cancellable::new()),
{ move |result| match result {
move |result| match result { Ok(response) => {
Ok(response) => { match GString::from_utf8_until_nul(
println!( response.0,
"Result: {:?}", ) {
GString::from_utf8_until_nul( Ok(data) => {
response.0 // Detect page meta
) let meta = Regex::split_simple(
); // @TODO r"^(\d+)?\s([\w]+\/[\w]+)?",
// @TODO connection.close(cancellable); data,
} RegexCompileFlags::DEFAULT,
Err(e) => { RegexMatchFlags::DEFAULT,
eprintln!( );
"Failed to read response: {:?}",
e //println!("{:?}", meta);
); //println!("Result: {}", data);
}
Err(_) => todo!(),
} }
// @TODO connection.close(cancellable);
}
Err(e) => {
eprintln!(
"Failed to read response: {:?}",
e
);
} }
}, },
); );

Loading…
Cancel
Save