pub struct TypeConverter { /* private fields */ }Expand description
XPath2-compatible type converter
Handles type conversions following XPath2/XQuery rules.
Implementations§
Source§impl TypeConverter
impl TypeConverter
Sourcepub fn with_validators(validators: ValidatorRegistry) -> Self
pub fn with_validators(validators: ValidatorRegistry) -> Self
Create with a custom validator registry
Sourcepub fn cast(
&self,
value: &XmlValue,
target: XmlTypeCode,
) -> ConversionResult<XmlValue>
pub fn cast( &self, value: &XmlValue, target: XmlTypeCode, ) -> ConversionResult<XmlValue>
Cast a value to the target type
This is the strict casting operation used by cast as.
Sourcepub fn to_boolean(&self, value: &XmlValue) -> ConversionResult<bool>
pub fn to_boolean(&self, value: &XmlValue) -> ConversionResult<bool>
Convert value to boolean (effective boolean value)
Sourcepub fn to_double(&self, value: &XmlValue) -> ConversionResult<f64>
pub fn to_double(&self, value: &XmlValue) -> ConversionResult<f64>
Convert value to double (numeric promotion)
Sourcepub fn to_decimal(&self, value: &XmlValue) -> ConversionResult<Decimal>
pub fn to_decimal(&self, value: &XmlValue) -> ConversionResult<Decimal>
Convert value to decimal
Sourcepub fn to_integer(&self, value: &XmlValue) -> ConversionResult<BigInt>
pub fn to_integer(&self, value: &XmlValue) -> ConversionResult<BigInt>
Convert value to integer
Sourcepub fn matches(&self, value: &XmlValue, seq_type: &SequenceType) -> bool
pub fn matches(&self, value: &XmlValue, seq_type: &SequenceType) -> bool
Check if value matches the given sequence type
Sourcepub fn promote_numeric(
&self,
left: XmlTypeCode,
right: XmlTypeCode,
) -> Option<XmlTypeCode>
pub fn promote_numeric( &self, left: XmlTypeCode, right: XmlTypeCode, ) -> Option<XmlTypeCode>
Apply type promotion for numeric operations
Returns the promoted type for two operands in an arithmetic operation.
Sourcepub fn promote_to(
&self,
value: &XmlValue,
target: XmlTypeCode,
) -> ConversionResult<XmlValue>
pub fn promote_to( &self, value: &XmlValue, target: XmlTypeCode, ) -> ConversionResult<XmlValue>
Promote a value to the target numeric type
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TypeConverter
impl !UnwindSafe for TypeConverter
impl Freeze for TypeConverter
impl Send for TypeConverter
impl Sync for TypeConverter
impl Unpin for TypeConverter
impl UnsafeUnpin for TypeConverter
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