Skip to content

Commit

Permalink
Reexport nix::Errno (#108)
Browse files Browse the repository at this point in the history
* Reexport nix

This is useful because the Error enum in its ApiError error variant exports that type, so in order to match on the error value it's necessary to use the same version of `nix` as this crate uses.

The idiom in this case is to reexport `nix` (or reexporting `Errno` would likely be fine as well, but I'm not sure if `nix` leaks in other ways maybe so I propose exporting the entire `nix` to be sure that it's correct.)

* Reexport only Errno
  • Loading branch information
Ten0 authored Oct 22, 2024
1 parent ed61660 commit 6c97a41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion examples/rados_striper.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#[cfg(feature = "rados_striper")]
use {
ceph::ceph as ceph_helpers, ceph::error::RadosError, nix::errno::Errno, std::env, std::str,
ceph::ceph as ceph_helpers,
ceph::error::{Errno, RadosError},
std::env,
std::str,
std::sync::Arc,
};

Expand Down
6 changes: 4 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ use uuid::Error as UuidError;

extern crate nix;

pub use nix::errno::Errno;

/// Custom error handling for the library
#[derive(Debug)]
pub enum RadosError {
FromUtf8Error(FromUtf8Error),
NulError(NulError),
Error(String),
IoError(Error),
ApiError(nix::errno::Errno),
ApiError(Errno),
IntoStringError(IntoStringError),
ParseIntError(ParseIntError),
ParseBoolError(ParseBoolError),
Expand Down Expand Up @@ -139,6 +141,6 @@ impl From<Error> for RadosError {
}
impl From<i32> for RadosError {
fn from(err: i32) -> RadosError {
RadosError::ApiError(nix::errno::Errno::from_raw(-err))
RadosError::ApiError(Errno::from_raw(-err))
}
}

0 comments on commit 6c97a41

Please sign in to comment.