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,
impl<Out, Map> GroundingProgram<Out, Map>where
Map: GroundingMapKind,
Sourcepub fn from_primitive<Markers>(
primitive: GroundingPrimitive<Out, Markers>,
) -> GroundingProgram<Out, Map>where
Markers: MarkerTuple + MarkersImpliedBy<Map>,
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;Sourcepub const fn primitive(&self) -> &GroundingPrimitive<Out>
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.
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.
Sourcepub fn run(&self, external: &[u8]) -> Option<GroundedCoord>
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.
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.
Sourcepub fn run(&self, external: &[u8]) -> Option<GroundedTuple<N>>
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>
impl<Out, Map> Clone for GroundingProgram<Out, Map>
Source§fn clone(&self) -> GroundingProgram<Out, Map>
fn clone(&self) -> GroundingProgram<Out, Map>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Out, Map> Debug for GroundingProgram<Out, Map>
impl<Out, Map> Debug for GroundingProgram<Out, Map>
Source§impl<Map> GroundingProgramRun<GroundedCoord> for GroundingProgram<GroundedCoord, Map>where
Map: GroundingMapKind,
impl<Map> GroundingProgramRun<GroundedCoord> for GroundingProgram<GroundedCoord, Map>where
Map: GroundingMapKind,
Source§fn run_program(&self, external: &[u8]) -> Option<GroundedCoord>
fn run_program(&self, external: &[u8]) -> Option<GroundedCoord>
Source§impl<const N: usize, Map> GroundingProgramRun<GroundedTuple<N>> for GroundingProgram<GroundedTuple<N>, Map>where
Map: GroundingMapKind,
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>>
fn run_program(&self, external: &[u8]) -> Option<GroundedTuple<N>>
Source§impl<Out, Map> Hash for GroundingProgram<Out, Map>
impl<Out, Map> Hash for GroundingProgram<Out, Map>
Source§impl<Out, Map> PartialEq for GroundingProgram<Out, Map>
impl<Out, Map> PartialEq for GroundingProgram<Out, Map>
Source§fn eq(&self, other: &GroundingProgram<Out, Map>) -> bool
fn eq(&self, other: &GroundingProgram<Out, Map>) -> bool
self and other values to be equal, and is used by ==.