pub trait PlutusDataCbor: PlutusDataJson {
// Required methods
fn from_cbor(cbor_hex: &str) -> Result<Self, WError>;
fn to_cbor(&self) -> Result<String, WError>;
}Expand description
Extension trait that adds CBOR serialization/deserialization capabilities
to any type implementing PlutusDataJson.
This trait is implemented automatically for all types that implement PlutusDataJson,
allowing direct conversion to/from CBOR hex strings.
§Example
ⓘ
use whisky_csl::PlutusDataCbor;
use whisky::data::PlutusDataJson;
#[derive(Debug, Clone, ConstrEnum)]
pub enum HydraOrderBookIntent {
PlaceOrderIntent(Box<(Order, MValue)>),
ModifyOrderIntent(Box<(Order, MValue)>),
}
// Deserialize from CBOR
let cbor_hex = "d87a9f...";
let intent = HydraOrderBookIntent::from_cbor(cbor_hex)?;
// Serialize back to CBOR
let cbor_out = intent.to_cbor()?;Required Methods§
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.