Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ libdd-dogstatsd-client @DataDog/apm-common-components-core
libdd-library-config*/ @DataDog/apm-sdk-capabilities
libdd-log*/ @DataDog/apm-common-components-core
libdd-profiling*/ @DataDog/libdatadog-profiling
libdd-proto-codec @DataDog/apm-common-components-core
libdd-telemetry*/ @DataDog/apm-common-components-core
libdd-tinybytes @DataDog/apm-common-components-core
libdd-trace-normalization @DataDog/serverless @DataDog/libdatadog-apm
Expand Down
59 changes: 47 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ members = [
"libdd-tinybytes",
"libdd-dogstatsd-client",
"libdd-log",
"libdd-log-ffi",
"libdd-log-ffi", "libdd-proto-codec",
]

# https://doc.rust-lang.org/cargo/reference/resolver.html
Expand Down
16 changes: 16 additions & 0 deletions libdd-proto-codec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "libdd-proto-codec"
rust-version.workspace = true
edition.workspace = true
version.workspace = true
license.workspace = true
authors.workspace = true

[dependencies]
bytes = { version = "1.4" }

[dev-dependencies]
prost = { version = "0.13", features = ["derive"] }
arbitrary = { version = "1", features = ["derive"] }
rand = "0.9"
criterion = { version = "0.5", features = ["html_reports"] }
33 changes: 33 additions & 0 deletions libdd-proto-codec/src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use core::hash;

#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, hash::Hash, PartialOrd, Ord)]
pub enum WireType {
Varint = 0,
Fixed64 = 1,
LengthDelimited = 2,
StartGroup = 3, // Deprecated in proto3, but still used in proto2.
EndGroup = 4, // Deprecated in proto3, but still used in proto2.
Fixed32 = 5,
}

impl WireType {
#[inline]
#[allow(unused)]
pub(crate) const fn from_u32(value: u32) -> Option<Self> {
match value {
0 => Some(WireType::Varint),
1 => Some(WireType::Fixed64),
2 => Some(WireType::LengthDelimited),
3 => Some(WireType::StartGroup),
4 => Some(WireType::EndGroup),
5 => Some(WireType::Fixed32),
_ => None,
}
}

#[inline]
pub(crate) const fn to_u32(self) -> u32 {
self as u32
}
}
Loading
Loading