pub struct BloqTemplate {
pub circuit: CoordCircuit,
pub detectors: Vec<TemplateDetector>,
pub repeat_states: Vec<TemplateRepeatState>,
pub boundary_flows: Vec<Flow>,
pub restarts: Vec<TemplateRestart>,
/* private fields */
}Expand description
A reusable circuit template and its local side tables.
Together they form the connection interface a persisted .bloq is edited against.
Pooled and shared by TemplateId; a TemplateInstance places one at an
offset.
Fields§
§circuit: CoordCircuitThe template’s circuit, in template-local qubit coordinates.
detectors: Vec<TemplateDetector>Detectors closing entirely within this template.
repeat_states: Vec<TemplateRepeatState>Loop-carried detector recurrences for the circuit’s repeat bodies.
boundary_flows: Vec<Flow>The template’s residual open flows — the only detectors instance lowering
must compose, since they close against a temporally adjacent node. The
retained connection interface that makes a persisted .bloq editable
(load → edit → recompose).
A flat list of fused boundary chains: each is one maximal open chain
spliced into a single start -> end flow carrying all its measurements,
in template-measurement-id space. Cross-chunk chains are threaded once at
build time, so entries are mutually independent (no entry’s end is
another’s start). A loop’s recurrence lives in repeat_states, not
here. Computed by the lowering flow pass and deduped per signature.
restarts: Vec<TemplateRestart>Restart syndromes for RepeatUntilSuccess regions instantiating this
template. The executor evaluates them after each sandboxed attempt.
Implementations§
Source§impl BloqTemplate
impl BloqTemplate
Sourcepub fn flatten(&self) -> Result<BloqTemplate, FlattenError>
pub fn flatten(&self) -> Result<BloqTemplate, FlattenError>
This template with every repeat block flattened away (see the module
docs): the circuit unrolled, repeat-scoped detectors expanded into one
top-level detector per iteration, loop-carried states resolved and
repeat_states cleared. Detector coordinates are copied verbatim per
iteration, matching what the emitter writes for each pass over a
repeat body. boundary_flows pass through unchanged: they name final
occurrences, which keep their ids.
A template without repeats (and without loop-state references) round trips unchanged.
§Errors
Returns FlattenError for invalid loop-state references, malformed
repeat bodies, or exhausted expansion limits.
Sourcepub fn flatten_with_limits(
&self,
limits: FlattenLimits,
) -> Result<BloqTemplate, FlattenError>
pub fn flatten_with_limits( &self, limits: FlattenLimits, ) -> Result<BloqTemplate, FlattenError>
Self::flatten with one allowance for circuit expansion and side-table
replay, including substituted loop-state parity terms.
§Errors
Returns FlattenError under the same conditions as Self::flatten,
including when limits is exhausted.
Source§impl BloqTemplate
impl BloqTemplate
Sourcepub fn new(circuit: CoordCircuit) -> Self
pub fn new(circuit: CoordCircuit) -> Self
Create a template containing only circuit.
Sourcepub fn with_parts(
circuit: CoordCircuit,
detectors: Vec<TemplateDetector>,
repeat_states: Vec<TemplateRepeatState>,
boundary_flows: Vec<Flow>,
restarts: Vec<TemplateRestart>,
) -> Self
pub fn with_parts( circuit: CoordCircuit, detectors: Vec<TemplateDetector>, repeat_states: Vec<TemplateRepeatState>, boundary_flows: Vec<Flow>, restarts: Vec<TemplateRestart>, ) -> Self
Create a template with all side tables supplied explicitly.