summaryrefslogtreecommitdiff
path: root/vendor/object/src/build/error.rs
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-02 18:36:06 -0600
committermo khan <mo@mokhan.ca>2025-07-02 18:36:06 -0600
commit8cdfa445d6629ffef4cb84967ff7017654045bc2 (patch)
tree22f0b0907c024c78d26a731e2e1f5219407d8102 /vendor/object/src/build/error.rs
parent4351c74c7c5f97156bc94d3a8549b9940ac80e3f (diff)
chore: add vendor directory
Diffstat (limited to 'vendor/object/src/build/error.rs')
-rw-r--r--vendor/object/src/build/error.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/object/src/build/error.rs b/vendor/object/src/build/error.rs
new file mode 100644
index 00000000..1e56780e
--- /dev/null
+++ b/vendor/object/src/build/error.rs
@@ -0,0 +1,43 @@
+use alloc::string::String;
+use core::{fmt, result};
+#[cfg(feature = "std")]
+use std::error;
+
+use crate::{read, write};
+
+/// The error type used within the build module.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Error(pub(super) String);
+
+impl Error {
+ pub(super) fn new(message: impl Into<String>) -> Self {
+ Error(message.into())
+ }
+}
+
+impl fmt::Display for Error {
+ #[inline]
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str(&self.0)
+ }
+}
+
+#[cfg(feature = "std")]
+impl error::Error for Error {}
+#[cfg(all(not(feature = "std"), core_error))]
+impl core::error::Error for Error {}
+
+impl From<read::Error> for Error {
+ fn from(error: read::Error) -> Error {
+ Error(format!("{}", error))
+ }
+}
+
+impl From<write::Error> for Error {
+ fn from(error: write::Error) -> Error {
+ Error(error.0)
+ }
+}
+
+/// The result type used within the build module.
+pub type Result<T> = result::Result<T, Error>;