[−][src]Trait dqcsim::common::converter::Converter
A type that can be used as a Converter.
Types implementing Converter can be used to detect inputs and link them to their outputs, and vice versa. The output is always a specific case of the input, so detection can fail in the sense that a given input is not an instance of the output type, while the opposite cannot fail this way.
A collection of types implementing Converter can be used in a ConverterMap to convert common types to plugin-specific types and back. This is primarily used for the C API, where the user cannot define their own converter traits to do the equivalent more ergonomically.
Associated Types
type Input
The more generic detector input type = constructor output type.
type Output
The more specific detector output type = constructor input type.
Required methods
fn detect(&self, input: &Self::Input) -> Result<Option<Self::Output>>
The detect function implements the detector function. The return values are as follows:
Ok(Some(O))
: successful matchOk(None)
: the input is not an instance of the output typeErr(_)
: something went wrong during detection
fn construct(&self, input: &Self::Output) -> Result<Self::Input>
The construct function implements the opposite of the detector function, converting the plugin-specific type to the more generic type.
Ok(O)
: successful constructionErr(_)
: something went wrong during construction
Implementors
impl Converter for MeasurementGateConverter
[src]
type Input = Gate
type Output = (Vec<QubitRef>, ArbData)
fn detect(&self, gate: &Gate) -> Result<Option<Self::Output>>
[src]
fn construct(&self, output: &Self::Output) -> Result<Gate>
[src]
impl Converter for PrepGateConverter
[src]
type Input = Gate
type Output = (Vec<QubitRef>, ArbData)
fn detect(&self, gate: &Gate) -> Result<Option<Self::Output>>
[src]
fn construct(&self, output: &Self::Output) -> Result<Gate>
[src]
impl<'c, I, K, O> Converter for ConverterMap<'c, K, I, O> where
K: Eq + Hash + Clone,
I: Eq + Hash + Clone,
O: Clone,
[src]
K: Eq + Hash + Clone,
I: Eq + Hash + Clone,
O: Clone,
type Input = I
type Output = (K, O)
fn detect(&self, input: &I) -> Result<Option<(K, O)>>
[src]
fn construct(&self, input: &(K, O)) -> Result<I>
[src]
impl<'f> Converter for CustomGateConverter<'f>
[src]
type Input = Gate
type Output = (Vec<QubitRef>, ArbData)
fn detect(&self, gate: &Self::Input) -> Result<Option<Self::Output>>
[src]
fn construct(&self, params: &Self::Output) -> Result<Self::Input>
[src]
impl<M> Converter for UnitaryGateConverter<M> where
M: Converter<Input = (Matrix, Option<usize>)>,
M::Output: FromArb + ToArb,
[src]
M: Converter<Input = (Matrix, Option<usize>)>,
M::Output: FromArb + ToArb,
type Input = Gate
type Output = (Vec<QubitRef>, ArbData)
fn detect(&self, gate: &Gate) -> Result<Option<Self::Output>>
[src]
fn construct(&self, output: &Self::Output) -> Result<Gate>
[src]
impl<T> Converter for UnitaryConverter<T> where
T: MatrixConverter,
[src]
T: MatrixConverter,
type Input = (Matrix, Option<usize>)
type Output = T::Parameters
fn detect(&self, input: &Self::Input) -> Result<Option<Self::Output>>
[src]
fn construct(&self, parameters: &Self::Output) -> Result<Self::Input>
[src]
impl<T> Converter for T where
T: MatrixConverter,
[src]
T: MatrixConverter,