Struct Hiding

Source
pub struct Hiding<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<N> Hiding<N>

Source

pub const fn hidden(cmr: Cmr, ctx: Context) -> 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<N: Clone> Clone for Hiding<N>

Source§

fn clone(&self) -> Hiding<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<N: CoreConstructible + HasCmr> CoreConstructible for Hiding<N>

Source§

fn iden(inference_context: &Context) -> Self

Source§

fn unit(inference_context: &Context) -> 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, entropy: FailEntropy) -> Self

Source§

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

Source§

fn inference_context(&self) -> &Context

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

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

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

fn bit_false(inference_context: &Context) -> Self

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

fn bit_true(inference_context: &Context) -> 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<N: Debug> Debug for Hiding<N>

Source§

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

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

impl<X, N> DisconnectConstructible<Option<X>> for Hiding<N>

Source§

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

Source§

impl<N: CoreConstructible> From<N> for Hiding<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<J, N> JetConstructible<J> for Hiding<N>

Source§

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

Source§

impl<N: PartialEq> PartialEq for Hiding<N>

Source§

fn eq(&self, other: &Hiding<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<W, N> WitnessConstructible<W> for Hiding<N>

Source§

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

Source§

impl<N: Eq> Eq for Hiding<N>

Source§

impl<N> StructuralPartialEq for Hiding<N>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<N> UnwindSafe for Hiding<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<J, X, W, T> Constructible<J, X, W> for T

Source§

fn from_inner( inference_context: &Context, 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