Skip to content

Commit

Permalink
move UnderlyingBytes impl for ShmHandle to ipc
Browse files Browse the repository at this point in the history
  • Loading branch information
ekump committed Sep 17, 2024
1 parent 02202f9 commit 8fb3ac6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 4 additions & 0 deletions ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ serde = { version = "1.0", default-features = false, features = ["derive"] }
tokio-serde = { version = "0.8", features = ["bincode"] }
tokio-util = { version = "0.6.9", features = ["codec"] }
libc = { version = "0.2" }
tinybytes = { path = "../tinybytes", optional = true }

# tarpc needed extensions to allow 1 way communication and to export some internal structs
tarpc = { path = "tarpc/tarpc", default-features = false, features = ["serde-transport"], package = "tarpc" }
Expand Down Expand Up @@ -63,3 +64,6 @@ path = "benches/ipc.rs"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(polyfill_glibc_memfd)'] }

[features]
tiny-bytes = ["tinybytes"]
5 changes: 5 additions & 0 deletions ipc/src/platform/mem_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use serde::{Deserialize, Serialize};
#[cfg(all(unix, not(target_os = "macos")))]
use std::os::unix::prelude::AsRawFd;
use std::{ffi::CString, io};
#[cfg(feature = "tiny-bytes")]
use tinybytes::UnderlyingBytes;

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct ShmHandle {
Expand Down Expand Up @@ -209,6 +211,9 @@ impl AsRef<[u8]> for MappedMem<ShmHandle> {
}
}

#[cfg(feature = "tiny-bytes")]
impl UnderlyingBytes for MappedMem<ShmHandle> {}

#[cfg(test)]
mod tests {
use crate::platform::{FileBackedHandle, NamedShmHandle, ShmHandle};
Expand Down
4 changes: 2 additions & 2 deletions sidecar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ datadog-trace-utils = { path = "../trace-utils" }
datadog-trace-normalization = { path = "../trace-normalization" }
datadog-remote-config = { path = "../remote-config" }
datadog-crashtracker = { path = "../crashtracker" }
tinybytes = { path = "../tinybytes", features = ["ipc"] }
tinybytes = { path = "../tinybytes" }

futures = { version = "0.3", default-features = false }
manual_future = "0.1.1"
Expand All @@ -35,7 +35,7 @@ hyper = { version = "0.14", features = ["client"], default-features = false }
lazy_static = "1.4"
pin-project = "1"

datadog-ipc = { path = "../ipc" }
datadog-ipc = { path = "../ipc", features = ["tiny-bytes"] }
datadog-ipc-macros = { path = "../ipc/macros" }

rand = "0.8.3"
Expand Down
6 changes: 3 additions & 3 deletions tinybytes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ pretty_assertions = "1.3"
proptest = {version = "1.5", features = ["std"], default-features = false}
test-case = "2.2"
serde_json = "1.0.127"
tinybytes = { path = ".", features = ["bytes_string", "serialization", "ipc"] }
tinybytes = { path = ".", features = ["bytes_string", "serialization"] }

[dependencies]
serde = { version = "1.0.209", optional = true }
datadog-ipc = { path = "../ipc", optional = true }
#datadog-ipc = { path = "../ipc", optional = true }

[features]
bytes_string = []
serialization = ["serde"]
ipc = ["datadog-ipc"]
#ipc = ["datadog-ipc"]
6 changes: 0 additions & 6 deletions tinybytes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "ipc")]
use datadog_ipc::platform::{MappedMem, ShmHandle};

use std::{
borrow, cmp, fmt, hash,
ops::{self, RangeBounds},
Expand Down Expand Up @@ -203,9 +200,6 @@ impl UnderlyingBytes for Vec<u8> {}
impl UnderlyingBytes for Box<[u8]> {}
impl UnderlyingBytes for String {}

#[cfg(feature = "ipc")]
impl UnderlyingBytes for MappedMem<ShmHandle> {}

// Implementations of common traits for `Bytes`.
impl Default for Bytes {
fn default() -> Self {
Expand Down

0 comments on commit 8fb3ac6

Please sign in to comment.