Skip to main content

deserialize

Function deserialize 

Source
pub fn deserialize<T: DeserializeOwned>(
    bytes: &[u8],
) -> Result<T, CachekitError>
Expand description

Deserialize an interop-mode MessagePack document, consuming exactly one document and rejecting trailing bytes (spec MUST).

Decode bounds: cachekit-core’s header walk (msgpack_document_len, run from crate::serializer::bounded_deserializer) runs first and rejects, with a decode bound: error, any document nested deeper than crate::serializer::MAX_DECODE_DEPTH or declaring more than the input can back.

The single-document rule is shared with auto-mode crate::serializer::deserialize: both refuse a Python-SDK-internal CK frame, whose first byte 0x43 ('C') is a complete one-byte MessagePack document (positive fixint 67). This reader’s only difference is the diagnostic: a payload with the 0x43 0x4B ("CK") prefix is named as the Python auto-mode frame instead of getting a generic trailing-bytes error.

§Errors

CachekitError::Serialization if the payload is a CK frame, is not valid MessagePack, or has trailing bytes after the first document.