1 file changed
+6
-3
crates/smbcloud-model/src/error_codes.rs
+6
-3
@@ -2,7 +2,7 @@ use core::fmt;
2
use serde::{Deserialize, Serialize};
3
use serde_repr::{Deserialize_repr, Serialize_repr};
4
use std::fmt::{Display, Formatter};
5
-use strum_macros::EnumIter;
5
+use strum_macros::{EnumIter, IntoStaticStr};
6
use thiserror::Error;
7
8
#[derive(Error, Serialize, Deserialize, Debug)]
@@ -20,7 +20,7 @@ impl Display for ErrorResponse {
20
}
21
}
22
23
-#[derive(Error, Serialize_repr, Deserialize_repr, Debug, EnumIter)]
23
+#[derive(Error, Serialize_repr, Deserialize_repr, Debug, EnumIter, IntoStaticStr)]
24
#[repr(i32)]
25
pub enum ErrorCode {
26
#[error("Unknown error.")]
@@ -66,6 +66,9 @@ impl ErrorCode {
66
}
67
68
pub fn rb_constant_name(&self) -> String {
69
- self.to_string()
69
+ // Using IntoStaticStr to get the variant name directly.
70
+ // self.into() will return a &'static str representing the variant name.
71
+ let variant_name_static_str: &'static str = self.into();
72
+ variant_name_static_str.to_string()
73
}
74
}