Converts `self` to a vector of values or return an error if `self` is a byte vector. # Returns Extracted vector of values # Examples ``` # use ciphercore_base::data_values::Value; let v = Value::from_vector( vec![ Value::from_vector(vec![]), Value::from_bytes(vec![1, 2, 3])]); let vv = v.to_vector().unwrap(); assert_eq!(vv.len(), 2); vv[0].access_vector(|v| { assert_eq!(*v, Vec:: ::new()
(&self)
| 672 | /// }).unwrap(); |
| 673 | /// ``` |
| 674 | pub fn to_vector(&self) -> Result<Vec<Value>> { |
| 675 | if let ValueBody::Vector(contents) = self.body.as_ref() { |
| 676 | Ok(contents.clone()) |
| 677 | } else { |
| 678 | Err(runtime_error!("Not a vector!")) |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | /// Converts `self` to a flattened array if it is a byte vector, then cast the array entries to `u8`. |
| 683 | /// |