Hiding

Struct Hiding 

Source
pub struct Hiding<'brand, N> { /* private fields */ }
Expand description

Wrapper that allows a node to be “hidden” during program construction.

§Program construction

When a program is constructed in post-order, the parent node is created based on its children. We use this fact to introduce special branching logic:

  1. A case node with a left “hidden” child and a right non-hidden child becomes assertr.
  2. A case node with a left non-hidden child and a right “hidden” child becomes assertl.
  3. Otherwise, any node with “hidden” children becomes itself “hidden” with an updated CMR.
  4. Any node with non-hidden children remains unchanged.

The program can be extracted from the wrapper when construction is finished. The program is invalid if the root node is “hidden”.

§Wrapping

A node can be wrapped via Hiding::from to add hiding support. A wrapped node can be converted into a “hidden” node via Hiding::hide. Finally, a “hidden” node can be manually created via Hiding::hidden.

§Virtual hidden nodes

The wrapper merely simulates hidden nodes. At no point are actual hidden nodes created. To stress this fact, I write “hidden” in quotation marks.

Implementations§

Source§

impl<'brand, N> Hiding<'brand, N>

Source

pub const fn hidden(cmr: Cmr, ctx: Context<'brand>) -> Self

Create a “hidden” node with the given CMR.

To enable the construction of possible parent nodes, the inference context of the current program must be passed.

Source

pub fn as_node(&self) -> Option<&N>

Access the non-hidden node inside in the wrapper.

Return None if the wrapped node is “hidden”.

Source

pub fn get_node(self) -> Option<N>

Consume the wrapper and return the non-hidden node that was inside.

Return None if the wrapped node is “hidden”.

Source§

impl<N: HasCmr> Hiding<'_, N>

Source

pub fn hide(self) -> Self

Ensure that the wrapped node is “hidden”. Convert non-hidden nodes into “hidden” nodes with the same CMR.

Trait Implementations§

Source§

impl<'brand, N: Clone> Clone for Hiding<'brand, N>

Source§

fn clone(&self) -> Hiding<'brand, N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'brand, N: CoreConstructible<'brand> + HasCmr> CoreConstructible<'brand> for Hiding<'brand, N>

Source§

fn iden(inference_context: &Context<'brand>) -> Self

Source§

fn unit(inference_context: &Context<'brand>) -> Self

Source§

fn injl(child: &Self) -> Self

Source§

fn injr(child: &Self) -> Self

Source§

fn take(child: &Self) -> Self

Source§

fn drop_(child: &Self) -> Self

Source§

fn comp(left: &Self, right: &Self) -> Result<Self, Error>

Source§

fn case(left: &Self, right: &Self) -> Result<Self, Error>

Source§

fn assertl(left: &Self, right: Cmr) -> Result<Self, Error>

Source§

fn assertr(left: Cmr, right: &Self) -> Result<Self, Error>

Source§

fn pair(left: &Self, right: &Self) -> Result<Self, Error>

Source§

fn fail(inference_context: &Context<'brand>, entropy: FailEntropy) -> Self

Source§

fn const_word(inference_context: &Context<'brand>, word: Word) -> Self

Source§

fn inference_context(&self) -> &Context<'brand>

Accessor for the type inference context used to create the object.
Source§

fn scribe(ctx: &Context<'brand>, value: &Value) -> Self

Create an expression that produces the given value. Read more
Source§

fn bit_false(inference_context: &Context<'brand>) -> Self

Create a DAG that takes any input and returns bit 0 as constant output. Read more
Source§

fn bit_true(inference_context: &Context<'brand>) -> Self

Create a DAG that takes any input and returns bit 1 as constant output. Read more
Source§

fn cond(left: &Self, right: &Self) -> Result<Self, Error>

Create a DAG that takes a bit and an input, such that the left child is evaluated on the input if the bit is 1 (if branch) and the right child is evaluated on the input otherwise (else branch). Read more
Source§

fn assert(child: &Self, hash: Cmr) -> Result<Self, Error>

Create a DAG that asserts that its child returns true, and fails otherwise. The hash identifies the assertion and is returned upon failure. Read more
Source§

fn not(child: &Self) -> Result<Self, Error>

Create a DAG that computes Boolean NOT of the child. Read more
Source§

fn and(left: &Self, right: &Self) -> Result<Self, Error>

Create a DAG that computes Boolean AND of the left and right child. Read more
Source§

fn or(left: &Self, right: &Self) -> Result<Self, Error>

Create a DAG that computes Boolean OR of the left and right. Read more
Source§

impl<'brand, N: Debug> Debug for Hiding<'brand, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'brand, X, N> DisconnectConstructible<'brand, Option<X>> for Hiding<'brand, N>
where N: DisconnectConstructible<'brand, Option<X>> + CoreConstructible<'brand> + HasCmr,

Source§

fn disconnect(left: &Self, right: &Option<X>) -> Result<Self, Error>

Source§

impl<'brand, N: CoreConstructible<'brand>> From<N> for Hiding<'brand, N>

Source§

fn from(node: N) -> Self

Converts to this type from the input type.
Source§

impl<N: HasCmr> HasCmr for Hiding<'_, N>

Source§

fn cmr(&self) -> Cmr

Access the Commitment Merkle Root.
Source§

impl<'brand, J, N> JetConstructible<'brand, J> for Hiding<'brand, N>
where N: JetConstructible<'brand, J> + CoreConstructible<'brand>,

Source§

fn jet(inference_context: &Context<'brand>, jet: J) -> Self

Source§

impl<'brand, N: PartialEq> PartialEq for Hiding<'brand, N>

Source§

fn eq(&self, other: &Hiding<'brand, N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'brand, W, N> WitnessConstructible<'brand, W> for Hiding<'brand, N>
where N: WitnessConstructible<'brand, W> + CoreConstructible<'brand>,

Source§

fn witness(inference_context: &Context<'brand>, witness: W) -> Self

Source§

impl<'brand, N: Eq> Eq for Hiding<'brand, N>

Source§

impl<'brand, N> StructuralPartialEq for Hiding<'brand, N>

Auto Trait Implementations§

§

impl<'brand, N> Freeze for Hiding<'brand, N>
where N: Freeze,

§

impl<'brand, N> RefUnwindSafe for Hiding<'brand, N>
where N: RefUnwindSafe,

§

impl<'brand, N> Send for Hiding<'brand, N>
where N: Send,

§

impl<'brand, N> Sync for Hiding<'brand, N>
where N: Sync,

§

impl<'brand, N> Unpin for Hiding<'brand, N>
where N: Unpin,

§

impl<'brand, N> UnwindSafe for Hiding<'brand, N>
where N: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<'brand, J, X, W, T> Constructible<'brand, J, X, W> for T
where T: DisconnectConstructible<'brand, X> + JetConstructible<'brand, J> + WitnessConstructible<'brand, W> + CoreConstructible<'brand>,

Source§

fn from_inner( inference_context: &Context<'brand>, inner: Inner<&Self, J, &X, W>, ) -> Result<Self, Error>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V