pub struct IonData<T>(/* private fields */);
Expand description
A wrapper for lifting Ion compatible data into using Ion-oriented comparisons (versus the Rust value semantics). This enables the default semantics to be what a Rust user expects for native values, but allows a user to opt-in to Ion’s structural equivalence/order.
Equivalence with respect to Ion values means that if two Ion values, X
and Y
, are equivalent,
they represent the same data and can be substituted for the other without loss of information.
Some types, such as Element
and Value
cannot be
used as the key of a map because they adhere to Rust value semantics—these types cannot implement
Eq
because they include NaN
as a possible value.
For use cases that are concerned with preserving the original Ion data, it is necessary to use
Ion value equivalence. Many common use cases, such as writing unit tests for code that produces
Ion, can be handled with IonData::eq()
.
For other use cases, such as using Ion data as the key of a map or passing Ion data to an
algorithm that depends on Eq
, you can lift values using IonData::from()
.
Generally, anything that is treated as Ion data (e.g., Element
and
Value
), can be converted to IonData
.
Hash
and Ord
are not guaranteed to be implemented for all IonData
, but when they are,
they are required to be consistent with Ion structural equality (and Eq
).
WARNING—The Ion specification does not define a total ordering over all Ion values. Do not depend on getting any particular result from Ord. Use it only as an opaque total ordering over all IonData. The algorithm used for Ord may change between versions.
Implementations§
Trait Implementations§
source§impl<T: IonEq + IonOrd> Ord for IonData<T>
impl<T: IonEq + IonOrd> Ord for IonData<T>
source§impl<T: IonEq> PartialEq<IonData<T>> for IonData<T>
impl<T: IonEq> PartialEq<IonData<T>> for IonData<T>
source§impl<T: IonEq + IonOrd> PartialOrd<IonData<T>> for IonData<T>
impl<T: IonEq + IonOrd> PartialOrd<IonData<T>> for IonData<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more