pub struct BloqTemplatePool { /* private fields */ }Expand description
A shared, append-only template pool.
Templates are keyed by TemplateId (the insertion index). Ids are never
reused or renumbered, so anything that
stores a TemplateId outside the pool — crate::PipePadding, the
decoder-wait specialization memo — can rely on it staying valid for the
program’s life.
Implementations§
Source§impl BloqTemplatePool
impl BloqTemplatePool
Sourcepub fn insert(&mut self, template: BloqTemplate) -> TemplateId
pub fn insert(&mut self, template: BloqTemplate) -> TemplateId
Insert an owned template and return its append-only id.
§Panics
Panics before insertion if the next id exceeds u32.
Unlike Self::insert, warmed qubit, circuit-analysis, and validation caches are
kept: an Arc-shared template is already immutable (the pool hands out
no &mut), so they cannot be stale. Clearing them here would deep-clone
every template the caller shares with a live pool.
§Panics
Panics before insertion if the next id exceeds u32.
Sourcepub fn get(&self, id: TemplateId) -> Option<&BloqTemplate>
pub fn get(&self, id: TemplateId) -> Option<&BloqTemplate>
Look up a template by id.
Sourcepub fn iter(&self) -> impl Iterator<Item = (TemplateId, &BloqTemplate)>
pub fn iter(&self) -> impl Iterator<Item = (TemplateId, &BloqTemplate)>
Iterate over templates in id order.
Borrow immutable template handles for importing into another pool without copying their circuits or discarding cached analyses.
Trait Implementations§
Source§impl Clone for BloqTemplatePool
impl Clone for BloqTemplatePool
Source§fn clone(&self) -> BloqTemplatePool
fn clone(&self) -> BloqTemplatePool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more