DocumentPlatformConversionMethodsV0

Trait DocumentPlatformConversionMethodsV0 

Source
pub trait DocumentPlatformConversionMethodsV0: Clone {
    // Required methods
    fn serialize(
        &self,
        document_type: DocumentTypeRef<'_>,
        data_contract: &DataContract,
        platform_version: &PlatformVersion,
    ) -> Result<Vec<u8>, ProtocolError>;
    fn serialize_specific_version(
        &self,
        document_type: DocumentTypeRef<'_>,
        data_contract: &DataContract,
        feature_version: FeatureVersion,
    ) -> Result<Vec<u8>, ProtocolError>;
    fn from_bytes(
        serialized_document: &[u8],
        document_type: DocumentTypeRef<'_>,
        platform_version: &PlatformVersion,
    ) -> Result<Self, ProtocolError>
       where Self: Sized;
    fn from_bytes_in_consensus(
        serialized_document: &[u8],
        document_type: DocumentTypeRef<'_>,
        platform_version: &PlatformVersion,
    ) -> Result<ConsensusValidationResult<Self>, ProtocolError>
       where Self: Sized;
}

Required Methods§

Source

fn serialize( &self, document_type: DocumentTypeRef<'_>, data_contract: &DataContract, platform_version: &PlatformVersion, ) -> Result<Vec<u8>, ProtocolError>

Serializes the document.

The serialization of a document follows the pattern: id 32 bytes + owner_id 32 bytes + encoded values byte arrays

Source

fn serialize_specific_version( &self, document_type: DocumentTypeRef<'_>, data_contract: &DataContract, feature_version: FeatureVersion, ) -> Result<Vec<u8>, ProtocolError>

Serializes the document.

The serialization of a document follows the pattern: id 32 bytes + owner_id 32 bytes + encoded values byte arrays

Source

fn from_bytes( serialized_document: &[u8], document_type: DocumentTypeRef<'_>, platform_version: &PlatformVersion, ) -> Result<Self, ProtocolError>
where Self: Sized,

Reads a serialized document and creates a Document from it.

Source

fn from_bytes_in_consensus( serialized_document: &[u8], document_type: DocumentTypeRef<'_>, platform_version: &PlatformVersion, ) -> Result<ConsensusValidationResult<Self>, ProtocolError>
where Self: Sized,

Reads a serialized document and creates a Document from it. This will return a ConsensusValidationResult instead when the error is happening in consensus (deserialization of a message from the network)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§