Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add wasm32-wasi target #49

Closed
ctaggart opened this issue Sep 20, 2020 · 2 comments · Fixed by #50
Closed

add wasm32-wasi target #49

ctaggart opened this issue Sep 20, 2020 · 2 comments · Fixed by #50

Comments

@ctaggart
Copy link

It would be great if we could target WASI. Currently:

Camerons-MacBook-Pro:path_abs cameron$ cargo build --target wasm32-wasi
    Updating crates.io index
   Compiling proc-macro2 v1.0.21
   Compiling memchr v2.3.3
   Compiling unicode-xid v0.2.1
   Compiling lazy_static v1.4.0
   Compiling syn v1.0.41
   Compiling serde_derive v1.0.116
   Compiling regex-syntax v0.6.18
   Compiling serde v1.0.116
   Compiling std_prelude v0.2.12
   Compiling thread_local v1.0.1
   Compiling aho-corasick v0.7.13
   Compiling quote v1.0.7
   Compiling regex v1.3.9
   Compiling stfu8 v0.2.4
   Compiling path_abs v0.5.0 (/Users/cameron/rs/path_abs)
error[E0425]: cannot find function `symlink_dir` in this scope
   --> src/dir.rs:308:9
    |
308 |         symlink_dir(&self, &dst).map_err(|err| {
    |         ^^^^^^^^^^^-------------
    |         |
    |         help: try calling `symlink_dir` as a method: `self.symlink_dir(&dst)`

error[E0425]: cannot find function `symlink_file` in this scope
   --> src/file.rs:413:9
    |
413 |         symlink_file(&self, &dst).map_err(|err| {
    |         ^^^^^^^^^^^^-------------
    |         |
    |         help: try calling `symlink_file` as a method: `self.symlink_file(&dst)`

warning: unused import: `OsString`
  --> src/ser.rs:16:23
   |
16 | use std::ffi::{OsStr, OsString};
   |                       ^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error[E0046]: not all trait items implemented, missing: `to_stfu8`
   --> src/ser.rs:150:1
    |
28  |       fn to_stfu8(&self) -> String;
    |       ----------------------------- `to_stfu8` from trait
...
150 | / impl<T> ToStfu8 for T
151 | | where
152 | |     T: Borrow<PathBuf>,
153 | | {
...   |
164 | |     }
165 | | }
    | |_^ missing `to_stfu8` in implementation

error[E0046]: not all trait items implemented, missing: `from_stfu8`
   --> src/ser.rs:167:1
    |
32  |       fn from_stfu8(s: &str) -> Result<Self, stfu8::DecodeError>;
    |       ----------------------------------------------------------- `from_stfu8` from trait
...
167 | / impl<T> FromStfu8 for T
168 | | where
169 | |     T: From<PathBuf>,
170 | | {
...   |
185 | |     }
186 | | }
    | |_^ missing `from_stfu8` in implementation

warning: use of deprecated associated function `std::error::Error::description`: use the Display impl or to_string()
   --> src/lib.rs:338:21
    |
338 |         self.io_err.description()
    |                     ^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

error: aborting due to 4 previous errors; 2 warnings emitted

Some errors have detailed explanations: E0046, E0425.
For more information about an error, try `rustc --explain E0046`.
error: could not compile `path_abs`

To learn more, run the command again with --verbose.
@ctaggart
Copy link
Author

For my use case, I'm just using pop_up and append that come from PathMut:

use path_abs::PathMut;
use std::path::PathBuf;

use super::Result;

pub fn path_join(a: &str, b: &str) -> Result<String> {
    let mut c = PathBuf::from(a);
    c.pop_up()?; // to directory
    c.append(b)?;
    Ok(c.as_path().to_str().unwrap().to_owned())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_path_join() -> Result<()> {
        let a = "../azure-rest-api-specs/specification/vmware/resource-manager/Microsoft.AVS/stable/2020-03-20/vmware.json";
        let b = "../../../../../common-types/resource-management/v1/types.json";
        let c = path_join(a, b)?;
        assert_eq!(
            c,
            "../azure-rest-api-specs/specification/common-types/resource-management/v1/types.json"
        );
        Ok(())
    }
}

@vitiral
Copy link
Owner

vitiral commented Sep 20, 2020

Agreed! I'm not actively using this library but will review and merge a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants