Skip to main content

GroundingProgram

Struct GroundingProgram 

Source
pub struct GroundingProgram<Out, Map>
where Map: GroundingMapKind,
{ /* private fields */ }
Expand description

v0.2.2 Phase J: sealed grounding program. A composition of combinators with a statically tracked marker tuple. Constructed only via GroundingProgram::from_primitive, which requires via the MarkersImpliedBy<Map> trait bound that the primitive’s marker tuple carries every property declared by Map: GroundingMapKind.

Implementations§

Source§

impl<Out, Map> GroundingProgram<Out, Map>
where Map: GroundingMapKind,

Source

pub fn from_primitive<Markers>( primitive: GroundingPrimitive<Out, Markers>, ) -> GroundingProgram<Out, Map>
where Markers: MarkerTuple + MarkersImpliedBy<Map>,

Foundation-verified constructor. Accepts a primitive whose marker tuple satisfies MarkersImpliedBy<Map>. Programs built from combinators whose marker tuple lacks a property Map requires are rejected at compile time — this is Phase J’s marquee correctness claim: misdeclarations fail to compile.

§Example: valid program
use uor_foundation::enforcement::{GroundingProgram, IntegerGroundingMap, combinators};
let prog: GroundingProgram<u64, IntegerGroundingMap> =
    GroundingProgram::from_primitive(combinators::interpret_le_integer::<u64>());
let _ = prog;
§Example: rejected misdeclaration
use uor_foundation::enforcement::{GroundingProgram, IntegerGroundingMap, combinators};
// digest returns (TotalMarker,) which does NOT satisfy
// MarkersImpliedBy<IntegerGroundingMap> — the line below fails to compile.
let prog: GroundingProgram<[u8; 32], IntegerGroundingMap> =
    GroundingProgram::from_primitive(combinators::digest::<[u8; 32]>());
let _ = prog;
Source

pub const fn primitive(&self) -> &GroundingPrimitive<Out>

Access the underlying primitive (erased marker tuple).

Source§

impl<Map> GroundingProgram<GroundedCoord, Map>
where Map: GroundingMapKind,

Phase K (target §4.3 / §9 criterion 1): foundation-supplied interpreter for grounding programs whose Out is GroundedCoord. Handles every op in the closed 12-combinator catalogue: leaf ops (ReadBytes, InterpretLeInteger, InterpretBeInteger, Digest, DecodeUtf8, DecodeJson, ConstValue, SelectField, SelectIndex) call interpret_leaf_op directly; composition ops (Then, AndThen, MapErr) walk the chain recorded in the primitive and thread external through each leaf step. The interpreter surfaces GroundedCoord::w8(byte) values; richer outputs compose through combinator chains producing GroundedTuple<N>. No ground() override exists after W4 closure — downstream provides only program(), and GroundingExt::ground is foundation-authored.

Source

pub fn run(&self, external: &[u8]) -> Option<GroundedCoord>

Run this program on external bytes, producing a GroundedCoord. Returns None if the input is malformed/undersized for the program’s op chain.

Source§

impl<const N: usize, Map> GroundingProgram<GroundedTuple<N>, Map>
where Map: GroundingMapKind,

W4 closure (target §4.3 + §9 criterion 1): foundation-supplied interpreter for programs producing GroundedTuple<N>. Splits external into N equal windows and runs the same dispatch that GroundingProgram<GroundedCoord, Map>::run performs on each window. Returns None if N == 0, the input is empty, the input length isn’t divisible by N, or any window fails.

Source

pub fn run(&self, external: &[u8]) -> Option<GroundedTuple<N>>

Run this program on external bytes, producing a GroundedTuple<N>.

Trait Implementations§

Source§

impl<Out, Map> Clone for GroundingProgram<Out, Map>
where Out: Clone, Map: Clone + GroundingMapKind,

Source§

fn clone(&self) -> GroundingProgram<Out, Map>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Out, Map> Debug for GroundingProgram<Out, Map>
where Out: Debug, Map: Debug + GroundingMapKind,

Source§

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

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

impl<Map> GroundingProgramRun<GroundedCoord> for GroundingProgram<GroundedCoord, Map>
where Map: GroundingMapKind,

Source§

fn run_program(&self, external: &[u8]) -> Option<GroundedCoord>

Run the program on external bytes.
Source§

impl<const N: usize, Map> GroundingProgramRun<GroundedTuple<N>> for GroundingProgram<GroundedTuple<N>, Map>
where Map: GroundingMapKind,

Source§

fn run_program(&self, external: &[u8]) -> Option<GroundedTuple<N>>

Run the program on external bytes.
Source§

impl<Out, Map> Hash for GroundingProgram<Out, Map>
where Out: Hash, Map: Hash + GroundingMapKind,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Out, Map> PartialEq for GroundingProgram<Out, Map>

Source§

fn eq(&self, other: &GroundingProgram<Out, Map>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<Out, Map> Copy for GroundingProgram<Out, Map>
where Out: Copy, Map: Copy + GroundingMapKind,

Source§

impl<Out, Map> Eq for GroundingProgram<Out, Map>
where Out: Eq, Map: Eq + GroundingMapKind,

Source§

impl<Out, Map> StructuralPartialEq for GroundingProgram<Out, Map>
where Map: GroundingMapKind,

Auto Trait Implementations§

§

impl<Out, Map> Freeze for GroundingProgram<Out, Map>

§

impl<Out, Map> RefUnwindSafe for GroundingProgram<Out, Map>
where Map: RefUnwindSafe, Out: RefUnwindSafe,

§

impl<Out, Map> Send for GroundingProgram<Out, Map>
where Map: Send, Out: Send,

§

impl<Out, Map> Sync for GroundingProgram<Out, Map>
where Map: Sync, Out: Sync,

§

impl<Out, Map> Unpin for GroundingProgram<Out, Map>
where Map: Unpin, Out: Unpin,

§

impl<Out, Map> UnsafeUnpin for GroundingProgram<Out, Map>

§

impl<Out, Map> UnwindSafe for GroundingProgram<Out, Map>
where Map: UnwindSafe, Out: 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<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> Same for T

Source§

type Output = T

Should always be Self
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.