From 0947e3c89b63337267bb252d1f6de3cbf20c41f2 Mon Sep 17 00:00:00 2001 From: Thomas BESSOU Date: Sat, 19 Oct 2024 17:31:37 +0200 Subject: [PATCH 1/2] 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.) --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index caccece..7cf6786 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -87,3 +87,5 @@ pub use crate::mon_command::MonCommand; pub type JsonData = serde_json::Value; pub type JsonValue = serde_json::Value; + +pub use nix; From 25fa4bea171896624c157f15b4a5c80dd9d386d0 Mon Sep 17 00:00:00 2001 From: Thomas BESSOU Date: Sun, 20 Oct 2024 14:15:17 +0200 Subject: [PATCH 2/2] Reexport only Errno --- examples/rados_striper.rs | 5 ++++- src/error.rs | 6 ++++-- src/lib.rs | 2 -- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/rados_striper.rs b/examples/rados_striper.rs index a66ac71..6a8fff3 100644 --- a/examples/rados_striper.rs +++ b/examples/rados_striper.rs @@ -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, }; diff --git a/src/error.rs b/src/error.rs index 9c72a2f..4074d53 100644 --- a/src/error.rs +++ b/src/error.rs @@ -25,6 +25,8 @@ use uuid::Error as UuidError; extern crate nix; +pub use nix::errno::Errno; + /// Custom error handling for the library #[derive(Debug)] pub enum RadosError { @@ -32,7 +34,7 @@ pub enum RadosError { NulError(NulError), Error(String), IoError(Error), - ApiError(nix::errno::Errno), + ApiError(Errno), IntoStringError(IntoStringError), ParseIntError(ParseIntError), ParseBoolError(ParseBoolError), @@ -139,6 +141,6 @@ impl From for RadosError { } impl From for RadosError { fn from(err: i32) -> RadosError { - RadosError::ApiError(nix::errno::Errno::from_raw(-err)) + RadosError::ApiError(Errno::from_raw(-err)) } } diff --git a/src/lib.rs b/src/lib.rs index 7cf6786..caccece 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -87,5 +87,3 @@ pub use crate::mon_command::MonCommand; pub type JsonData = serde_json::Value; pub type JsonValue = serde_json::Value; - -pub use nix;