netstack3_base

Trait 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§