Trait xcm_executor::traits::Convert
source · pub trait Convert<A: Clone, B: Clone> {
fn convert(value: A) -> Result<B, A> { ... }
fn convert_ref(value: impl Borrow<A>) -> Result<B, ()> { ... }
fn reverse(value: B) -> Result<A, B> { ... }
fn reverse_ref(value: impl Borrow<B>) -> Result<A, ()> { ... }
}Expand description
Generic third-party conversion trait. Use this when you don’t want to force the user to use default
implementations of From and Into for the types you wish to convert between.
One of convert/convert_ref and reverse/reverse_ref MUST be implemented. If possible, implement
convert_ref, since this will never result in a clone. Use convert when you definitely need to consume
the source value.
Can be amalgamated into tuples. If any of the tuple elements converts into Ok(_) it short circuits. Otherwise returns
the Err(_) of the last failing conversion (or Err(()) for ref conversions).
Provided Methods§
sourcefn convert(value: A) -> Result<B, A>
fn convert(value: A) -> Result<B, A>
Convert from value (of type A) into an equivalent value of type B, Err if not possible.
fn convert_ref(value: impl Borrow<A>) -> Result<B, ()>
sourcefn reverse(value: B) -> Result<A, B>
fn reverse(value: B) -> Result<A, B>
Convert from value (of type B) into an equivalent value of type A, Err if not possible.