Skip to main content

decode

Function decode 

Source
pub fn decode<'a, T: Deserialize<'a>>(bytes: &'a [u8]) -> Result<T>
Expand description

Decode bytes in dora’s binary wire format, requiring the value to consume the entire slice.

This is the only decode entry point, and the trailing-byte check is why it must stay that way: postcard’s own from_bytes ignores trailing bytes where bincode (this protocol’s previous codec) rejected them, and two call sites depend on the strict behaviour.

  • The zenoh attachment filters read a decode failure as “not a dora message, ignore it”. A foreign publisher whose attachment merely starts with something shaped like a metadata::Metadata would otherwise be accepted as genuine.
  • The length-prefixed daemon↔node frames read a decode failure as a desynced or incompatible peer. A frame longer than the value it carries is evidence of exactly that, and must not be silently truncated.