diff --git a/zenoh-flow-nodes/src/messages.rs b/zenoh-flow-nodes/src/messages.rs index 3692c710..09877e33 100644 --- a/zenoh-flow-nodes/src/messages.rs +++ b/zenoh-flow-nodes/src/messages.rs @@ -147,7 +147,7 @@ pub struct LinkMessage { impl Ord for LinkMessage { fn cmp(&self, other: &Self) -> Ordering { - self.get_timestamp().cmp(other.get_timestamp()) + self.timestamp().cmp(other.timestamp()) } } @@ -159,20 +159,12 @@ impl PartialOrd for LinkMessage { impl PartialEq for LinkMessage { fn eq(&self, other: &Self) -> bool { - self.get_timestamp() == other.get_timestamp() + self.timestamp() == other.timestamp() } } impl Eq for LinkMessage {} -impl Deref for LinkMessage { - type Target = Payload; - - fn deref(&self) -> &Self::Target { - &self.payload - } -} - impl LinkMessage { pub fn new(payload: Payload, timestamp: Timestamp) -> Self { Self { payload, timestamp } @@ -188,13 +180,29 @@ impl LinkMessage { } } - /// Return the [Timestamp] associated with this message. + /// Return the [Payload] associated with this [LinkMessage]. // - // NOTE: This method is used by, at least, our Python API. + // NOTE: Used by our Python API. 🐍 + pub fn payload(&self) -> &Payload { + &self.payload + } + + /// Return the [Timestamp] associated with this message. + #[deprecated( + since = "0.6.0-alpha.3", + note = "This method will be deprecated in the next major version of Zenoh-Flow in favour of `timestamp()`." + )] pub fn get_timestamp(&self) -> &Timestamp { &self.timestamp } + /// Return the [Timestamp] associated with this message. + // + // NOTE: Used by our Python API. 🐍 + pub fn timestamp(&self) -> &Timestamp { + &self.timestamp + } + /// Serialises the [LinkMessage] using [bincode] into the given `buffer`. /// /// The `inner_buffer` is used to serialise (if need be) the [Payload] contained inside the diff --git a/zenoh-flow-runtime/src/runners/builtin/zenoh/sink.rs b/zenoh-flow-runtime/src/runners/builtin/zenoh/sink.rs index d62e90ec..9efccbfc 100644 --- a/zenoh-flow-runtime/src/runners/builtin/zenoh/sink.rs +++ b/zenoh-flow-runtime/src/runners/builtin/zenoh/sink.rs @@ -204,7 +204,7 @@ Caused by: #[cfg(not(feature = "shared-memory"))] { - data.try_as_bytes_into(&mut payload_buffer)?; + data.payload().try_as_bytes_into(&mut payload_buffer)?; publisher .put(payload_buffer) .res()