App JSON Settings
App settings as JSON format stored in file and available via read-by-key and write-by-key.
Aims a tiny settings manager with reasonably few dependencies.
Examples
Rust - as Tauri backend
use JsonSettigs;
Instead of exe_dir()
, config_dir()
is available, which points to app dir in user config dir.
TypeScript - as Tauri frontend
import { invoke } from '@tauri-apps/api/core'
interface ReadByKeyResponse {
key: string
value: unknown
file_exists: boolean
key_exists: boolean
}
const read = (key: string): Promise<unknown> => {
return invoke('settings_read_by_key', { key: key }).then((res) => {
const _res = res as ReadByKeyResponse
if (!_res.file_exists || !_res.key_exists) return undefined
return _res.value
})
}
const write = <T>(key: string, value: any) => {
invoke('settings_write_by_key', { key: key, value: value })
}
settings.json