Skip to content

Commit

Permalink
Add #[repr(transparent)]
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln committed Nov 21, 2024
1 parent 6859ad1 commit 0ca2b3a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libs/telemetry/src/capturing/ng/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::models::{LogLevel, SpanKind, TraceSpan};

#[derive(Debug, Display, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[display(fmt = "{}", _0)]
#[repr(transparent)]
struct SerializableNonZeroU64(NonZeroU64);

impl Serialize for SerializableNonZeroU64 {
Expand Down Expand Up @@ -46,6 +47,7 @@ impl<'de> Deserialize<'de> for SerializableNonZeroU64 {

#[derive(Debug, Display, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[display(fmt = "{}", _0)]
#[repr(transparent)]
struct SerializableU64(u64);

impl Serialize for SerializableU64 {
Expand Down Expand Up @@ -74,6 +76,7 @@ impl<'de> Deserialize<'de> for SerializableU64 {
/// A unique identifier for a span. It maps directly to [`tracing::span::Id`] assigned by
/// [`tracing_subscriber::registry::Registry`].
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
#[repr(transparent)]
pub struct SpanId(SerializableNonZeroU64);

impl From<&tracing::span::Id> for SpanId {
Expand Down Expand Up @@ -101,6 +104,7 @@ impl From<tracing::span::Id> for SpanId {
/// request IDs that are guaranteed to be unique for a very long period of time (although they
/// still don't necessarily have to be unique for the whole lifetime of the process).
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
#[repr(transparent)]
pub struct RequestId(SerializableU64);

impl RequestId {
Expand Down

0 comments on commit 0ca2b3a

Please sign in to comment.