substrate_stellar_sdk/xdr/impls/
data_value.rs

1use crate::{compound_types::LimitedVarOpaque, DataValue, StellarSdkError};
2use sp_std::vec::Vec;
3
4pub trait IntoDataValue {
5    fn into_data_value(self) -> Result<DataValue, StellarSdkError>;
6}
7
8impl IntoDataValue for DataValue {
9    fn into_data_value(self) -> Result<DataValue, StellarSdkError> {
10        Ok(self)
11    }
12}
13
14impl<T: AsRef<[u8]>> IntoDataValue for T {
15    fn into_data_value(self) -> Result<DataValue, StellarSdkError> {
16        let value = self.as_ref();
17        LimitedVarOpaque::new(Vec::from(value))
18    }
19}