dpp/document/serialization_traits/cbor_conversion/v0/
mod.rs

1use crate::version::PlatformVersion;
2use crate::ProtocolError;
3use ciborium::Value as CborValue;
4
5pub trait DocumentCborMethodsV0 {
6    /// Reads a CBOR-serialized document and creates a Document from it.
7    /// If Document and Owner IDs are provided, they are used, otherwise they are created.
8    fn from_cbor(
9        document_cbor: &[u8],
10        document_id: Option<[u8; 32]>,
11        owner_id: Option<[u8; 32]>,
12        platform_version: &PlatformVersion,
13    ) -> Result<Self, ProtocolError>
14    where
15        Self: Sized;
16    fn to_cbor_value(&self) -> Result<CborValue, ProtocolError>;
17    /// Serializes the Document to CBOR.
18    fn to_cbor(&self) -> Result<Vec<u8>, ProtocolError>;
19}