pub trait BidirectionalConverter<Input, Output> {
// Required methods
fn convert(&self, a: Input) -> Output;
fn convert_back(&self, b: Output) -> Input;
}
Expand description
Provides functions for converting infallibly between types.
This trait can be implemented on types that allow converting between two
related types. It has two blanket implementations: ()
for identity
conversions, i.e. Input=Output
, and [UninstantiableConverter
] as an
uninstantiable type that implements the trait for any input and output.
Required Methods§
Sourcefn convert(&self, a: Input) -> Output
fn convert(&self, a: Input) -> Output
Converts an instance of Input
into an instance of Output
.
Sourcefn convert_back(&self, b: Output) -> Input
fn convert_back(&self, b: Output) -> Input
Converts an instance of Output
into an instance of Input
.