mirror of
https://github.com/TxtDot/vigi.git
synced 2025-02-23 04:33:14 +03:00
feat: txt rendering
This commit is contained in:
parent
48f4a63b6b
commit
1ddef2c247
8 changed files with 660 additions and 16 deletions
|
@ -1,15 +1,29 @@
|
|||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use dalet::{Argument, Body, Tag};
|
||||
|
||||
mod types;
|
||||
use types::VigiError;
|
||||
|
||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
async fn process_input(input: String) -> Result<Vec<Tag>, VigiError> {
|
||||
// TODO: Implement mime type, language, protocol or search detection
|
||||
// TODO: Implement text links parsing
|
||||
|
||||
match reqwest::get(input).await {
|
||||
Ok(res) => match res.text().await {
|
||||
Ok(res) => Ok(vec![dalet::Tag::new(0, Body::Text(res), Argument::Null)]),
|
||||
Err(err) => Err(VigiError::ParseError(err.to_string())),
|
||||
},
|
||||
Err(err) => Err(VigiError::NetworkError(err.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![greet])
|
||||
.invoke_handler(tauri::generate_handler![process_input])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
|
7
src-tauri/src/types.rs
Normal file
7
src-tauri/src/types.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum VigiError {
|
||||
NetworkError(String),
|
||||
ParseError(String),
|
||||
}
|
Loading…
Add table
Reference in a new issue