pub struct Recoverable<'a>(/* private fields */);Expand description
A Postcard option containing a bounded, borrowed Postcard payload.
Absence is the byte zero. Presence is the byte one followed by the byte length and contents of the payload. A present unit has a zero byte length. Consumers explicitly project this value to enable recovery.
Implementations§
Source§impl<'a> Recoverable<'a>
impl<'a> Recoverable<'a>
Sourcepub fn write<T: Serialize + ?Sized>(
context: &WriteContext<'_>,
value: &T,
scratch: &'a mut [u8],
) -> Result<Self, Error>
pub fn write<T: Serialize + ?Sized>( context: &WriteContext<'_>, value: &T, scratch: &'a mut [u8], ) -> Result<Self, Error>
Write a present branch payload into caller-owned scratch storage.
§Errors
Returns an allowance, output capacity, or payload serialization error.
Sourcepub fn project<T: Deserialize<'a>, R>(
self,
context: &ReadContext<'_>,
project: impl FnOnce(T, &RecoveryContext<'_>) -> Result<R, Error>,
) -> Result<Option<R>, Error>
pub fn project<T: Deserialize<'a>, R>( self, context: &ReadContext<'_>, project: impl FnOnce(T, &RecoveryContext<'_>) -> Result<R, Error>, ) -> Result<Option<R>, Error>
Project a complete branch and map a marked incompatibility to absence.
The projection must check the whole branch, including known siblings after an incompatible value, and propagate errors from those checks.
§Errors
Returns a malformed payload, allowance refusal, or projection error. Recovery requires a mark from RecoveryContext::required_open or RecoveryContext::missing_required.