Skip to content

Commit cea3837

Browse files
committed
Bytes is an optional dependency
1 parent 1b21f14 commit cea3837

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

rust/bufferfish-core/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ edition = "2024"
1212

1313
[dependencies]
1414
unicode-width = { version = "0.2", optional = true }
15-
bytes = "1"
15+
bytes = { version = "1", optional = true }
1616

1717
[features]
1818
default = []
1919
pretty-print = ["unicode-width"]
20+
with-bytes = ["bytes"]

rust/bufferfish-core/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ impl From<Bufferfish> for Vec<u8> {
705705
}
706706
}
707707

708+
#[cfg(feature = "bytes")]
708709
impl From<bytes::Bytes> for Bufferfish {
709710
fn from(bytes: bytes::Bytes) -> Self {
710711
Self {
@@ -715,12 +716,14 @@ impl From<bytes::Bytes> for Bufferfish {
715716
}
716717
}
717718

719+
#[cfg(feature = "bytes")]
718720
impl From<Bufferfish> for bytes::Bytes {
719721
fn from(buffer: Bufferfish) -> Self {
720722
bytes::Bytes::from(buffer.inner.into_inner())
721723
}
722724
}
723725

726+
#[cfg(feature = "bytes")]
724727
impl From<&Bufferfish> for bytes::Bytes {
725728
fn from(buffer: &Bufferfish) -> Self {
726729
bytes::Bytes::copy_from_slice(buffer.as_ref())

0 commit comments

Comments
 (0)