mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-29 13:41:51 +02:00
Split up HTTP sending logic (#320)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
pub mod api_client;
|
||||
pub mod error;
|
||||
pub mod platform;
|
||||
pub mod serde;
|
||||
pub mod window;
|
||||
|
||||
23
src-tauri/yaak-common/src/serde.rs
Normal file
23
src-tauri/yaak-common/src/serde.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub fn get_bool(v: &Value, key: &str, fallback: bool) -> bool {
|
||||
match v.get(key) {
|
||||
None => fallback,
|
||||
Some(v) => v.as_bool().unwrap_or(fallback),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_str<'a>(v: &'a Value, key: &str) -> &'a str {
|
||||
match v.get(key) {
|
||||
None => "",
|
||||
Some(v) => v.as_str().unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_str_map<'a>(v: &'a BTreeMap<String, Value>, key: &str) -> &'a str {
|
||||
match v.get(key) {
|
||||
None => "",
|
||||
Some(v) => v.as_str().unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user