pub struct ChoiceWrapper<T> {
pub inner: T,
}Expand description
A transparent wrapper that places an xs:choice enum as the $value
(element content) of its parent XML element.
quick-xml only supports serializing and deserializing enum newtype
variants when they appear as element content via a $value-renamed field.
This struct is that one-field wrapper.
§Access
Use the public .inner field to access the wrapped enum, or use
ChoiceWrapper::new(value) / From<T> to construct one.
use mx20022_model::common::ChoiceWrapper;
#[derive(Debug, PartialEq)]
enum MyChoice { A(String), B(u32) }
let w = ChoiceWrapper::new(MyChoice::A("hello".to_owned()));
// Access inner value
match &w.inner {
MyChoice::A(s) => assert_eq!(s, "hello"),
MyChoice::B(_) => unreachable!(),
}Fields§
§inner: TThe wrapped xs:choice enum value.
Implementations§
Source§impl<T> ChoiceWrapper<T>
impl<T> ChoiceWrapper<T>
Trait Implementations§
Source§impl<T: Clone> Clone for ChoiceWrapper<T>
impl<T: Clone> Clone for ChoiceWrapper<T>
Source§fn clone(&self) -> ChoiceWrapper<T>
fn clone(&self) -> ChoiceWrapper<T>
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<T: Debug> Debug for ChoiceWrapper<T>
impl<T: Debug> Debug for ChoiceWrapper<T>
Source§impl<T> Deref for ChoiceWrapper<T>
impl<T> Deref for ChoiceWrapper<T>
Source§impl<T> DerefMut for ChoiceWrapper<T>
impl<T> DerefMut for ChoiceWrapper<T>
Source§impl<'de, T> Deserialize<'de> for ChoiceWrapper<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ChoiceWrapper<T>where
T: Deserialize<'de>,
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
Source§impl<T> From<T> for ChoiceWrapper<T>
impl<T> From<T> for ChoiceWrapper<T>
Source§impl<T: PartialEq> PartialEq for ChoiceWrapper<T>
impl<T: PartialEq> PartialEq for ChoiceWrapper<T>
Source§impl<T> Serialize for ChoiceWrapper<T>where
T: Serialize,
impl<T> Serialize for ChoiceWrapper<T>where
T: Serialize,
Source§impl<T: Validatable> Validatable for ChoiceWrapper<T>
impl<T: Validatable> Validatable for ChoiceWrapper<T>
Source§fn validate_constraints(
&self,
path: &str,
violations: &mut Vec<ConstraintViolation>,
)
fn validate_constraints( &self, path: &str, violations: &mut Vec<ConstraintViolation>, )
Validate XSD constraints on this value and all nested children. Read more
impl<T: Eq> Eq for ChoiceWrapper<T>
impl<T> StructuralPartialEq for ChoiceWrapper<T>
Auto Trait Implementations§
impl<T> Freeze for ChoiceWrapper<T>where
T: Freeze,
impl<T> RefUnwindSafe for ChoiceWrapper<T>where
T: RefUnwindSafe,
impl<T> Send for ChoiceWrapper<T>where
T: Send,
impl<T> Sync for ChoiceWrapper<T>where
T: Sync,
impl<T> Unpin for ChoiceWrapper<T>where
T: Unpin,
impl<T> UnsafeUnpin for ChoiceWrapper<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for ChoiceWrapper<T>where
T: UnwindSafe,
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