diff --git a/crates/traits/src/codec.rs b/crates/traits/src/codec.rs index 32137f4..26dd0c6 100644 --- a/crates/traits/src/codec.rs +++ b/crates/traits/src/codec.rs @@ -110,9 +110,19 @@ impl CodecConfig for DefaultCodecConfig { /// Trait for decoding bytes into a type with configuration. pub trait Decode: Sized { /// Decode from bytes using the given configuration. + /// + /// # Errors + /// + /// Returns [`CodecError`] if decoding fails due to invalid data, + /// size limits exceeded, or other configuration violations. fn decode(bytes: &[u8], config: &C) -> Result; /// Decode from Bytes using the given configuration. + /// + /// # Errors + /// + /// Returns [`CodecError`] if decoding fails due to invalid data, + /// size limits exceeded, or other configuration violations. fn decode_bytes(bytes: &Bytes, config: &C) -> Result { Self::decode(bytes.as_ref(), config) } @@ -121,9 +131,17 @@ pub trait Decode: Sized { /// Trait for encoding a type into bytes. pub trait Encode { /// Encode into bytes. + /// + /// # Errors + /// + /// Returns [`CodecError`] if encoding fails. fn encode(&self) -> Result; /// Encode into a `Vec`. + /// + /// # Errors + /// + /// Returns [`CodecError`] if encoding fails. fn encode_vec(&self) -> Result, CodecError> { self.encode().map(|b| b.to_vec()) } diff --git a/crates/traits/src/runtime.rs b/crates/traits/src/runtime.rs index d14537d..253b9fb 100644 --- a/crates/traits/src/runtime.rs +++ b/crates/traits/src/runtime.rs @@ -22,6 +22,10 @@ impl Handle { } /// Wait for the task to complete. + /// + /// # Errors + /// + /// Returns [`JoinError`] if the task was cancelled or panicked. pub async fn join(self) -> Result { self.inner.await.map_err(JoinError) }