Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make binary propagator take byte slice instead of vec #32

Merged
merged 2 commits into from
Feb 13, 2024
Merged
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
4 changes: 4 additions & 0 deletions opentelemetry-contrib/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## vNext

### Changed

- Update `BinaryFormat::deserialize_from_bytes` to take a byte slice instead of a Vec [#32](https://github.com/open-telemetry/opentelemetry-rust-contrib/pull/32)

## v0.13.0

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ where

fn deserialize_from_base64(&self, base64: &str) -> SpanContext {
if let Ok(bytes) = decode(base64.as_bytes()) {
self.deserialize_from_bytes(bytes)
self.deserialize_from_bytes(&bytes)
} else {
SpanContext::empty_context()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait BinaryFormat {
fn serialize_into_bytes(&self, context: &SpanContext) -> [u8; 29];

/// Deserializes a span context from a byte array.
fn deserialize_from_bytes(&self, bytes: Vec<u8>) -> SpanContext;
fn deserialize_from_bytes(&self, bytes: &[u8]) -> SpanContext;
}

/// Extracts and injects `SpanContext`s from byte arrays.
Expand Down Expand Up @@ -46,7 +46,7 @@ impl BinaryFormat for BinaryPropagator {
}

/// Deserializes a span context from a byte array.
fn deserialize_from_bytes(&self, bytes: Vec<u8>) -> SpanContext {
fn deserialize_from_bytes(&self, bytes: &[u8]) -> SpanContext {
if bytes.is_empty() {
return SpanContext::empty_context();
}
Expand Down Expand Up @@ -172,7 +172,7 @@ mod tests {
let propagator = BinaryPropagator::new();

for (context, data) in from_bytes_data() {
assert_eq!(propagator.deserialize_from_bytes(data), context)
assert_eq!(propagator.deserialize_from_bytes(&data), context)
}
}
}
Loading