Skip to content

Commit

Permalink
chore: run fmt + clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrani committed May 8, 2024
1 parent abb570d commit c2c6a54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src-tauri/src/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use tauri::{Error as TauriError, LogicalPosition, LogicalSize, Manager, State, Window, AppHandle, EventTarget};
use tauri::{Error as TauriError, LogicalPosition, LogicalSize, Manager, State, Window};

use crate::app::setup::{create_webview, PORTAL};
use crate::config::Config;
Expand Down Expand Up @@ -47,13 +47,13 @@ pub async fn update_history(window: Window, state: History) {
}

#[tauri::command]
pub async fn get_persona(personas: State<'_, PersonasState>, id: Option<&str>) -> Result<Persona, TauriError> {
pub async fn get_persona(
personas: State<'_, PersonasState>,
id: Option<&str>,
) -> Result<Persona, TauriError> {
let persona_guard = personas.0.lock().await;

let id = match id {
Some(id) => id,
None => "me"
};
let id = id.unwrap_or("me");

let persona = persona_guard.get_persona(id);
Ok(persona)
Expand Down
19 changes: 8 additions & 11 deletions src-tauri/src/persona/mod.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use std::collections::HashMap;
use futures_util::lock::Mutex;
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

pub mod sites;

use sites::Site;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Persona {
sites: Vec<Site>
sites: Vec<Site>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Personas {
personas: HashMap::<String, Persona>
personas: HashMap<String, Persona>,
}

pub struct PersonasState(pub Mutex<Personas>);
Expand Down Expand Up @@ -53,7 +53,8 @@ impl Personas {
return None;
}

let personas_contents = Self::read_personas_file(personas_file_path.to_string_lossy().as_ref());
let personas_contents =
Self::read_personas_file(personas_file_path.to_string_lossy().as_ref());

Some(Self::get_yaml_content(&personas_contents))
}
Expand All @@ -76,12 +77,8 @@ impl Personas {

pub fn get_yaml_content(personas_content: &str) -> Self {
match serde_yaml::from_str(personas_content) {
Ok(contents) => {
Self { ..contents }
}
Err(_) => {
Self::get_default_personas()
},
Ok(contents) => Self { ..contents },
Err(_) => Self::get_default_personas(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/persona/sites.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Site {
id: String,
url: String,
url: String,
}

0 comments on commit c2c6a54

Please sign in to comment.