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

Enhancement request: use i32 as error type for Filesystem #33

Open
asomers opened this issue Feb 9, 2022 · 2 comments
Open

Enhancement request: use i32 as error type for Filesystem #33

asomers opened this issue Feb 9, 2022 · 2 comments

Comments

@asomers
Copy link
Contributor

asomers commented Feb 9, 2022

fuse3 currently defines a custom Error type, a wrapper around errno, which implements From<i32>. That is pretty convenient to use for a crate whose native errors are also i32, or whose custom error type can implement Into<fuse3::Errno>. However, it's a problem for a crate whose custom error type comes from a third crate, because Rust's trait impl rules don't allow a crate to implement From or Into to convert between two external types.
Looking at the source, it seems the fuse3::Error type only exists for the sake of a few one-line convenience methods like is_not_exist and new_not_exist. I think the switch could be done with almost no net change in line count. If you agree, I can prepare a PR.

@Sherlock-Holo
Copy link
Owner

the fuse3::Errno also implement From<std::io::Error>, that can help user convert the io error to Errno, or when they want to convert to the io::Error, they can use err.into() directly

@asomers
Copy link
Contributor Author

asomers commented Feb 14, 2022

Which helps if their crate's native error type is io::Error, but not other arbitrary error types. For example, in my case it's nix::Errno.

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

No branches or pull requests

2 participants