Skip to content

Commit

Permalink
ui: Use BTreeMap instead of HashMap to return sorted output.
Browse files Browse the repository at this point in the history
  • Loading branch information
brocaar committed Nov 21, 2024
1 parent 3e45ba1 commit c6492e1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions interface/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::fs;
use std::path::Path;

Expand Down Expand Up @@ -34,8 +34,8 @@ pub fn update_vendor(path: &Path, dir: &str, v: &VendorConfiguration) -> Result<
Ok(())
}

pub fn get_vendors(path: &Path) -> Result<HashMap<String, VendorConfiguration>> {
let mut out = HashMap::new();
pub fn get_vendors(path: &Path) -> Result<BTreeMap<String, VendorConfiguration>> {
let mut out = BTreeMap::new();
let vendors = fs::read_dir(path.join("vendors"))?;
for vendor in vendors {
let vendor = vendor?.path();
Expand Down Expand Up @@ -106,8 +106,8 @@ pub fn update_codec(
pub fn get_codecs(
path: &Path,
vendor_dir: &str,
) -> Result<HashMap<String, (String, String, String)>> {
let mut out = HashMap::new();
) -> Result<BTreeMap<String, (String, String, String)>> {
let mut out = BTreeMap::new();
let codecs_path = path.join("vendors").join(vendor_dir).join("codecs");
let codecs = fs::read_dir(&codecs_path)?;

Expand Down Expand Up @@ -182,8 +182,8 @@ pub fn update_profile(
pub fn get_profiles(
path: &Path,
vendor_dir: &str,
) -> Result<HashMap<String, ProfileConfiguration>> {
let mut out = HashMap::new();
) -> Result<BTreeMap<String, ProfileConfiguration>> {
let mut out = BTreeMap::new();
let profiles = fs::read_dir(path.join("vendors").join(vendor_dir).join("profiles"))?;
for profile in profiles {
let profile = profile?.path();
Expand Down Expand Up @@ -246,8 +246,8 @@ pub fn update_device(
create_device(path, vendor_dir, name, device)
}

pub fn get_devices(path: &Path, vendor_dir: &str) -> Result<HashMap<String, DeviceConfiguration>> {
let mut out = HashMap::new();
pub fn get_devices(path: &Path, vendor_dir: &str) -> Result<BTreeMap<String, DeviceConfiguration>> {
let mut out = BTreeMap::new();
let devices = fs::read_dir(path.join("vendors").join(vendor_dir).join("devices"))?;
for device in devices {
let device = device?.path();
Expand Down

0 comments on commit c6492e1

Please sign in to comment.