@@ -2321,7 +2321,7 @@ impl Url {
2321
2321
/// # run().unwrap();
2322
2322
/// # }
2323
2323
/// ```
2324
- #[ cfg( any( unix, windows, target_os = "redox" ) ) ]
2324
+ #[ cfg( any( unix, windows, target_os = "redox" , target_os = "wasi" ) ) ]
2325
2325
#[ allow( clippy:: result_unit_err) ]
2326
2326
pub fn from_file_path < P : AsRef < Path > > ( path : P ) -> Result < Url , ( ) > {
2327
2327
let mut serialization = "file://" . to_owned ( ) ;
@@ -2358,7 +2358,7 @@ impl Url {
2358
2358
///
2359
2359
/// Note that `std::path` does not consider trailing slashes significant
2360
2360
/// and usually does not include them (e.g. in `Path::parent()`).
2361
- #[ cfg( any( unix, windows, target_os = "redox" ) ) ]
2361
+ #[ cfg( any( unix, windows, target_os = "redox" , target_os = "wasi" ) ) ]
2362
2362
#[ allow( clippy:: result_unit_err) ]
2363
2363
pub fn from_directory_path < P : AsRef < Path > > ( path : P ) -> Result < Url , ( ) > {
2364
2364
let mut url = Url :: from_file_path ( path) ?;
@@ -2475,7 +2475,7 @@ impl Url {
2475
2475
/// (That is, if the percent-decoded path contains a NUL byte or,
2476
2476
/// for a Windows path, is not UTF-8.)
2477
2477
#[ inline]
2478
- #[ cfg( any( unix, windows, target_os = "redox" ) ) ]
2478
+ #[ cfg( any( unix, windows, target_os = "redox" , target_os = "wasi" ) ) ]
2479
2479
#[ allow( clippy:: result_unit_err) ]
2480
2480
pub fn to_file_path ( & self ) -> Result < PathBuf , ( ) > {
2481
2481
if let Some ( segments) = self . path_segments ( ) {
@@ -2679,12 +2679,15 @@ impl<'de> serde::Deserialize<'de> for Url {
2679
2679
}
2680
2680
}
2681
2681
2682
- #[ cfg( any( unix, target_os = "redox" ) ) ]
2682
+ #[ cfg( any( unix, target_os = "redox" , target_os = "wasi" ) ) ]
2683
2683
fn path_to_file_url_segments (
2684
2684
path : & Path ,
2685
2685
serialization : & mut String ,
2686
2686
) -> Result < ( u32 , HostInternal ) , ( ) > {
2687
+ #[ cfg( any( unix, target_os = "redox" ) ) ]
2687
2688
use std:: os:: unix:: prelude:: OsStrExt ;
2689
+ #[ cfg( target_os = "wasi" ) ]
2690
+ use std:: os:: wasi:: prelude:: OsStrExt ;
2688
2691
if !path. is_absolute ( ) {
2689
2692
return Err ( ( ) ) ;
2690
2693
}
@@ -2774,13 +2777,16 @@ fn path_to_file_url_segments_windows(
2774
2777
Ok ( ( host_end, host_internal) )
2775
2778
}
2776
2779
2777
- #[ cfg( any( unix, target_os = "redox" ) ) ]
2780
+ #[ cfg( any( unix, target_os = "redox" , target_os = "wasi" ) ) ]
2778
2781
fn file_url_segments_to_pathbuf (
2779
2782
host : Option < & str > ,
2780
2783
segments : str:: Split < ' _ , char > ,
2781
2784
) -> Result < PathBuf , ( ) > {
2782
2785
use std:: ffi:: OsStr ;
2786
+ #[ cfg( any( unix, target_os = "redox" ) ) ]
2783
2787
use std:: os:: unix:: prelude:: OsStrExt ;
2788
+ #[ cfg( target_os = "wasi" ) ]
2789
+ use std:: os:: wasi:: prelude:: OsStrExt ;
2784
2790
2785
2791
if host. is_some ( ) {
2786
2792
return Err ( ( ) ) ;
0 commit comments