Trait Ternary

Source
pub trait Ternary {
    type Boolean;
    type Output;

    // Required method
    fn ternary(
        condition: &Self::Boolean,
        first: &Self,
        second: &Self,
    ) -> Self::Output
       where Self: Sized;
}
Expand description

Trait for ternary operations.

Required Associated Types§

Required Methods§

Source

fn ternary( condition: &Self::Boolean, first: &Self, second: &Self, ) -> Self::Output
where Self: Sized,

Returns first if condition is true, otherwise returns second.

Trait Implementations§

Source§

impl<A> Metrics<dyn Ternary<Boolean = Boolean<A>, Output = ComputeKey<A>>> for ComputeKey<A>
where A: Aleo,

Source§

type Case = (Mode, Mode, Mode)

Source§

fn count( case: &<ComputeKey<A> as Metrics<dyn Ternary<Boolean = Boolean<A>, Output = ComputeKey<A>>>>::Case, ) -> Count

Returns the number of constants, public inputs, private inputs, and constraints.
Source§

impl<A> Metrics<dyn Ternary<Boolean = Boolean<A>, Output = Signature<A>>> for Signature<A>
where A: Aleo,

Source§

type Case = (Mode, Mode, Mode)

Source§

fn count( case: &<Signature<A> as Metrics<dyn Ternary<Boolean = Boolean<A>, Output = Signature<A>>>>::Case, ) -> Count

Returns the number of constants, public inputs, private inputs, and constraints.
Source§

impl<E> Metrics<dyn Ternary<Boolean = Boolean<E>, Output = Address<E>>> for Address<E>
where E: Environment,

Source§

type Case = (Mode, Mode, Mode)

Source§

fn count( case: &<Address<E> as Metrics<dyn Ternary<Boolean = Boolean<E>, Output = Address<E>>>>::Case, ) -> Count

Returns the number of constants, public inputs, private inputs, and constraints.
Source§

impl<E> Metrics<dyn Ternary<Boolean = Boolean<E>, Output = Field<E>>> for Field<E>
where E: Environment,

Source§

type Case = (Mode, Mode, Mode)

Source§

fn count( case: &<Field<E> as Metrics<dyn Ternary<Boolean = Boolean<E>, Output = Field<E>>>>::Case, ) -> Count

Returns the number of constants, public inputs, private inputs, and constraints.
Source§

impl<E> Metrics<dyn Ternary<Boolean = Boolean<E>, Output = Group<E>>> for Group<E>
where E: Environment,

Source§

type Case = (Mode, Mode, Mode)

Source§

fn count( case: &<Group<E> as Metrics<dyn Ternary<Boolean = Boolean<E>, Output = Group<E>>>>::Case, ) -> Count

Returns the number of constants, public inputs, private inputs, and constraints.
Source§

impl<E, I> Metrics<dyn Ternary<Boolean = Boolean<E>, Output = Integer<E, I>>> for Integer<E, I>
where E: Environment, I: IntegerType,

Source§

type Case = (Mode, Mode, Mode)

Source§

fn count( case: &<Integer<E, I> as Metrics<dyn Ternary<Boolean = Boolean<E>, Output = Integer<E, I>>>>::Case, ) -> Count

Returns the number of constants, public inputs, private inputs, and constraints.
Source§

impl<A> OutputMode<dyn Ternary<Boolean = Boolean<A>, Output = ComputeKey<A>>> for ComputeKey<A>
where A: Aleo,

Source§

type Case = (CircuitType<Boolean<A>>, Mode, Mode)

Source§

fn output_mode( parameter: &<ComputeKey<A> as OutputMode<dyn Ternary<Boolean = Boolean<A>, Output = ComputeKey<A>>>>::Case, ) -> Mode

Returns the mode of the output.
Source§

impl<A> OutputMode<dyn Ternary<Boolean = Boolean<A>, Output = Signature<A>>> for Signature<A>
where A: Aleo,

Source§

type Case = (CircuitType<Boolean<A>>, Mode, Mode)

Source§

fn output_mode( parameter: &<Signature<A> as OutputMode<dyn Ternary<Boolean = Boolean<A>, Output = Signature<A>>>>::Case, ) -> Mode

Returns the mode of the output.
Source§

impl<E> OutputMode<dyn Ternary<Boolean = Boolean<E>, Output = Address<E>>> for Address<E>
where E: Environment,

Source§

type Case = (CircuitType<Boolean<E>>, Mode, Mode)

Source§

fn output_mode( parameter: &<Address<E> as OutputMode<dyn Ternary<Boolean = Boolean<E>, Output = Address<E>>>>::Case, ) -> Mode

Returns the mode of the output.
Source§

impl<E> OutputMode<dyn Ternary<Boolean = Boolean<E>, Output = Field<E>>> for Field<E>
where E: Environment,

Source§

type Case = (CircuitType<Boolean<E>>, Mode, Mode)

Source§

fn output_mode( parameter: &<Field<E> as OutputMode<dyn Ternary<Boolean = Boolean<E>, Output = Field<E>>>>::Case, ) -> Mode

Returns the mode of the output.
Source§

impl<E> OutputMode<dyn Ternary<Boolean = Boolean<E>, Output = Group<E>>> for Group<E>
where E: Environment,

Source§

type Case = (CircuitType<Boolean<E>>, Mode, Mode)

Source§

fn output_mode( parameter: &<Group<E> as OutputMode<dyn Ternary<Boolean = Boolean<E>, Output = Group<E>>>>::Case, ) -> Mode

Returns the mode of the output.
Source§

impl<E, I> OutputMode<dyn Ternary<Boolean = Boolean<E>, Output = Integer<E, I>>> for Integer<E, I>
where E: Environment, I: IntegerType,

Source§

type Case = (CircuitType<Boolean<E>>, Mode, Mode)

Source§

fn output_mode( case: &<Integer<E, I> as OutputMode<dyn Ternary<Boolean = Boolean<E>, Output = Integer<E, I>>>>::Case, ) -> Mode

Returns the mode of the output.

Implementations on Foreign Types§

Source§

impl<E> Ternary for Address<E>
where E: Environment,

Source§

fn ternary( condition: &<Address<E> as Ternary>::Boolean, first: &Address<E>, second: &Address<E>, ) -> <Address<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Address<E>

Source§

impl<E> Ternary for Boolean<E>
where E: Environment,

Source§

fn ternary( condition: &<Boolean<E> as Ternary>::Boolean, first: &Boolean<E>, second: &Boolean<E>, ) -> <Boolean<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Boolean<E>

Source§

impl<E> Ternary for Field<E>
where E: Environment,

Source§

fn ternary( condition: &<Field<E> as Ternary>::Boolean, first: &Field<E>, second: &Field<E>, ) -> <Field<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Field<E>

Source§

impl<E> Ternary for Group<E>
where E: Environment,

Source§

fn ternary( condition: &<Group<E> as Ternary>::Boolean, first: &Group<E>, second: &Group<E>, ) -> <Group<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Group<E>

Source§

impl<E> Ternary for Scalar<E>
where E: Environment,

Source§

fn ternary( condition: &<Scalar<E> as Ternary>::Boolean, first: &Scalar<E>, second: &Scalar<E>, ) -> <Scalar<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Scalar<E>

Source§

impl<E> Ternary for StringType<E>
where E: Environment,

Source§

fn ternary( condition: &<StringType<E> as Ternary>::Boolean, first: &StringType<E>, second: &StringType<E>, ) -> <StringType<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = StringType<E>

Source§

impl<E, I> Ternary for Integer<E, I>
where E: Environment, I: IntegerType,

Source§

fn ternary( condition: &<Integer<E, I> as Ternary>::Boolean, first: &Integer<E, I>, second: &Integer<E, I>, ) -> <Integer<E, I> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Integer<E, I>

Source§

impl<N> Ternary for ComputeKey<N>
where N: Network,

Source§

fn ternary( condition: &<ComputeKey<N> as Ternary>::Boolean, first: &ComputeKey<N>, second: &ComputeKey<N>, ) -> <ComputeKey<N> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<N>

Source§

type Output = ComputeKey<N>

Source§

impl<N> Ternary for Signature<N>
where N: Network,

Source§

fn ternary( condition: &<Signature<N> as Ternary>::Boolean, first: &Signature<N>, second: &Signature<N>, ) -> <Signature<N> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<N>

Source§

type Output = Signature<N>

Source§

impl<T> Ternary for Box<T>
where T: Ternary,

Source§

fn ternary( condition: &<Box<T> as Ternary>::Boolean, first: &Box<T>, second: &Box<T>, ) -> <Box<T> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = <T as Ternary>::Boolean

Source§

type Output = Box<<T as Ternary>::Output>

Implementors§

Source§

impl<A> Ternary for snarkvm_circuit::modules::ComputeKey<A>
where A: Aleo,

Source§

impl<A> Ternary for snarkvm_circuit::modules::Signature<A>
where A: Aleo,

Source§

impl<E> Ternary for snarkvm_circuit::modules::Address<E>
where E: Environment,

Source§

impl<E> Ternary for snarkvm_circuit::modules::Boolean<E>
where E: Environment,

Source§

impl<E> Ternary for snarkvm_circuit::modules::Field<E>
where E: Environment,

Source§

impl<E> Ternary for snarkvm_circuit::modules::Group<E>
where E: Environment,

Source§

impl<E> Ternary for snarkvm_circuit::modules::Scalar<E>
where E: Environment,

Source§

impl<E, I> Ternary for snarkvm_circuit::modules::modules::integers::Integer<E, I>
where E: Environment, I: IntegerType,

Source§

impl<E, const VARIANT: usize> Ternary for BooleanHash<E, VARIANT>
where E: Environment,