dpp/document/v0/
platform_value_conversion.rs

1use crate::document::serialization_traits::DocumentPlatformValueMethodsV0;
2use crate::document::DocumentV0;
3use crate::version::PlatformVersion;
4use crate::ProtocolError;
5use platform_value::Value;
6use std::collections::BTreeMap;
7
8impl DocumentPlatformValueMethodsV0<'_> for DocumentV0 {
9    fn to_map_value(&self) -> Result<BTreeMap<String, Value>, ProtocolError> {
10        Ok(platform_value::to_value(self)?.into_btree_string_map()?)
11    }
12
13    fn into_map_value(self) -> Result<BTreeMap<String, Value>, ProtocolError> {
14        Ok(platform_value::to_value(self)?.into_btree_string_map()?)
15    }
16
17    fn into_value(self) -> Result<Value, ProtocolError> {
18        Ok(platform_value::to_value(self)?)
19    }
20
21    fn to_object(&self) -> Result<Value, ProtocolError> {
22        Ok(platform_value::to_value(self)?)
23    }
24
25    fn from_platform_value(
26        document_value: Value,
27        _platform_version: &PlatformVersion,
28    ) -> Result<Self, ProtocolError> {
29        Ok(platform_value::from_value(document_value)?)
30    }
31}