11use rhai:: { CustomType , TypeBuilder } ;
2- use std:: path:: PathBuf ;
32
43#[ derive( Debug , Clone , CustomType ) ]
54pub struct SystemInfo {
@@ -24,11 +23,11 @@ pub struct SystemInfo {
2423#[ derive( Debug , Clone , CustomType ) ]
2524pub struct SystemInfoPaths {
2625 #[ rhai_type( readonly) ]
27- cache_dir : PathBuf ,
26+ cache_dir : String ,
2827 #[ rhai_type( readonly) ]
29- config_dir : PathBuf ,
28+ config_dir : String ,
3029 #[ rhai_type( readonly) ]
31- home_dir : PathBuf ,
30+ home_dir : String ,
3231}
3332
3433impl SystemInfo {
@@ -45,9 +44,15 @@ impl SystemInfo {
4544 desktop_env : whoami:: desktop_env ( ) . to_string ( ) ,
4645 platform : whoami:: platform ( ) . to_string ( ) ,
4746 paths : SystemInfoPaths {
48- cache_dir : dirs:: cache_dir ( ) . unwrap_or_else ( || "unknown" . into ( ) ) ,
49- config_dir : dirs:: config_dir ( ) . unwrap_or_else ( || "unknown" . into ( ) ) ,
50- home_dir : dirs:: home_dir ( ) . unwrap_or_else ( || "unknown" . into ( ) ) ,
47+ cache_dir : dirs:: cache_dir ( )
48+ . map ( |x| x. to_string_lossy ( ) . to_string ( ) )
49+ . unwrap_or_else ( || "unknown" . into ( ) ) ,
50+ config_dir : dirs:: config_dir ( )
51+ . map ( |x| x. to_string_lossy ( ) . to_string ( ) )
52+ . unwrap_or_else ( || "unknown" . into ( ) ) ,
53+ home_dir : dirs:: home_dir ( )
54+ . map ( |x| x. to_string_lossy ( ) . to_string ( ) )
55+ . unwrap_or_else ( || "unknown" . into ( ) ) ,
5156 } ,
5257 }
5358 }
@@ -57,9 +62,9 @@ impl SystemInfo {
5762 hostname : "canonical-hostname" . to_string ( ) ,
5863 username : "canonical-username" . to_string ( ) ,
5964 paths : SystemInfoPaths {
60- cache_dir : ( PathBuf :: from ( "/canonical/cache" ) ) ,
61- config_dir : ( PathBuf :: from ( "/canonical/config" ) ) ,
62- home_dir : ( PathBuf :: from ( "/canonical/home" ) ) ,
65+ cache_dir : "/canonical/cache" . to_string ( ) ,
66+ config_dir : "/canonical/config" . to_string ( ) ,
67+ home_dir : "/canonical/home" . to_string ( ) ,
6368 } ,
6469 distro : "distro" . to_string ( ) ,
6570 device_name : "devicename" . to_string ( ) ,
0 commit comments