use btreemap for manifests

This commit is contained in:
Lucas Nogueira 2023-07-31 12:52:44 -03:00
parent 41961e7de0
commit e729a9c83f
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7
3 changed files with 27 additions and 27 deletions

View File

@ -6,7 +6,7 @@ use tauri_utils::plugin::Capability;
pub use tauri_utils::plugin::{Manifest, ManifestMap, ScopeType};
use std::{
collections::HashMap,
collections::BTreeMap,
env::{var_os, vars_os},
fs::{read_to_string, write},
path::PathBuf,
@ -49,7 +49,7 @@ pub fn set_manifest(mut manifest: Manifest) {
}
pub(crate) fn manifests() -> ManifestMap {
let mut manifests = HashMap::new();
let mut manifests = BTreeMap::new();
for (key, value) in vars_os() {
let key = key.to_string_lossy();

View File

@ -7,7 +7,7 @@
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
collections::BTreeMap,
ops::{Deref, DerefMut},
};
@ -155,10 +155,10 @@ impl Manifest {
/// A collection mapping a plugin name to its manifest.
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct ManifestMap(HashMap<String, Manifest>);
pub struct ManifestMap(BTreeMap<String, Manifest>);
impl Deref for ManifestMap {
type Target = HashMap<String, Manifest>;
type Target = BTreeMap<String, Manifest>;
fn deref(&self) -> &Self::Target {
&self.0
@ -171,8 +171,8 @@ impl DerefMut for ManifestMap {
}
}
impl From<HashMap<String, Manifest>> for ManifestMap {
fn from(value: HashMap<String, Manifest>) -> Self {
impl From<BTreeMap<String, Manifest>> for ManifestMap {
fn from(value: BTreeMap<String, Manifest>) -> Self {
Self(value)
}
}

View File

@ -16,6 +16,26 @@
}
],
"plugins": {
"__app__": {
"default_capability": null,
"capabilities": [
{
"id": "allow-all-api-commands",
"component": null,
"description": "Allows all application defined commands",
"features": [
"log_operation",
"perform_request"
],
"scope": {
"allowed": [],
"blocked": []
}
}
],
"features": [],
"scope_type": []
},
"event": {
"plugin": "event",
"default_capability": null,
@ -51,26 +71,6 @@
],
"scope_type": []
},
"__app__": {
"default_capability": null,
"capabilities": [
{
"id": "allow-all-api-commands",
"component": null,
"description": "Allows all application defined commands",
"features": [
"log_operation",
"perform_request"
],
"scope": {
"allowed": [],
"blocked": []
}
}
],
"features": [],
"scope_type": []
},
"path": {
"plugin": "path",
"default_capability": null,