Trait netstack3_base::BidirectionalConverter

source ·
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§

source

fn convert(&self, a: Input) -> Output

Converts an instance of Input into an instance of Output.

source

fn convert_back(&self, b: Output) -> Input

Converts an instance of Output into an instance of Input.

Implementations on Foreign Types§

source§

impl<I> BidirectionalConverter<I, I> for ()

source§

fn convert_back(&self, value: I) -> I

source§

fn convert(&self, value: I) -> I

Implementors§