diff --git a/src/validator/cbor.rs b/src/validator/cbor.rs index d2e424b3..95ae83b6 100644 --- a/src/validator/cbor.rs +++ b/src/validator/cbor.rs @@ -371,6 +371,11 @@ impl<'a> CBORValidator<'a> { } } + /// Extract the underlying CBOR Value. + pub fn extract_cbor(self) -> Value { + self.cbor + } + fn validate_array_items( &mut self, token: &ArrayItemToken, @@ -3903,4 +3908,14 @@ mod tests { Ok(()) } + + #[test] + fn extract_cbor() { + use ciborium::value::Value; + + let cbor = Value::Float(1.23); + let cddl = cddl_from_str("start = any", true).unwrap(); + let cv = CBORValidator::new(&cddl, cbor, None); + assert_eq!(cv.extract_cbor(), Value::Float(1.23)); + } }