use libdd_trace_model::TraceText; use libdd_trace_utils::span::SpanText; use serde::Serialize; use std::borrow::Borrow; use std::fmt::*; use std::hash::{Hash, Hasher}; use std::sync::Arc; #[derive(Default, Debug, Eq, PartialEq, Serialize, Clone)] pub struct SpanString(pub Arc); impl Hash for SpanString { fn hash(&self, state: &mut H) { // Hash the string content, not the Arc pointer self.0.as_ref().hash(state); } } impl Borrow for SpanString { fn borrow(&self) -> &str { &self.0 } } impl TraceText for SpanString { fn from_static(value: &'static str) -> Self { Self::from(value) } } impl SpanText for SpanString { fn from_static_str(value: &'static str) -> Self { SpanString(Arc::from(value)) } fn from_owned(value: String) -> Self { SpanString(Arc::from(value)) } } impl From for SpanString { fn from(s: String) -> SpanString { SpanString(Arc::from(s)) } } impl From<&str> for SpanString { fn from(value: &str) -> SpanString { SpanString(Arc::from(value)) } } impl Display for SpanString { fn fmt(&self, formatter: &mut Formatter) -> Result { write!(formatter, "{}", self.0) } }