pub struct UniversalStruct {
pub fields: Vec<WrappedField>,
}Expand description
A collection of individually-wrapped fields.
Each field carries its own Base64 encoding and SHA-256 fingerprint, so a single corrupted field can be identified without re-verifying the rest.
Fields§
§fields: Vec<WrappedField>Implementations§
Source§impl UniversalStruct
impl UniversalStruct
Sourcepub fn wrap_fields(fields: &[(&str, &str)]) -> Self
pub fn wrap_fields(fields: &[(&str, &str)]) -> Self
Wrap a list of (name, value) field pairs
Sourcepub fn verify_all(&self) -> StructVerifyResult
pub fn verify_all(&self) -> StructVerifyResult
Verify all fields - returns detailed per-field results
Sourcepub fn get(&self, name: &str) -> Result<String, UniversalError>
pub fn get(&self, name: &str) -> Result<String, UniversalError>
Get a verified field value by name
Sourcepub fn to_map(&self) -> Result<HashMap<String, String>, UniversalError>
pub fn to_map(&self) -> Result<HashMap<String, String>, UniversalError>
Get all verified fields as a HashMap
Sourcepub fn assert_intact(&self)
pub fn assert_intact(&self)
Assert all fields intact - panics with field names if violated
Sourcepub fn to_json(&self) -> Result<String, UniversalError>
pub fn to_json(&self) -> Result<String, UniversalError>
Serialize this struct to a JSON string.
Sourcepub fn from_json(s: &str) -> Result<Self, UniversalError>
pub fn from_json(s: &str) -> Result<Self, UniversalError>
Deserialize a struct from a JSON string.
Trait Implementations§
Source§impl Clone for UniversalStruct
impl Clone for UniversalStruct
Source§fn clone(&self) -> UniversalStruct
fn clone(&self) -> UniversalStruct
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UniversalStruct
impl Debug for UniversalStruct
Source§impl<'de> Deserialize<'de> for UniversalStruct
impl<'de> Deserialize<'de> for UniversalStruct
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for UniversalStruct
impl RefUnwindSafe for UniversalStruct
impl Send for UniversalStruct
impl Sync for UniversalStruct
impl Unpin for UniversalStruct
impl UnsafeUnpin for UniversalStruct
impl UnwindSafe for UniversalStruct
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more