pub struct CircuitMap {
state: CircuitMapState,
shreds_in_layer: HashMap<LayerId, Vec<NodeId>>,
label_to_shred_id: HashMap<String, NodeId>,
layer_label_to_layer_id: HashMap<String, LayerId>,
layer_visibility: HashMap<LayerId, LayerVisibility>,
node_location: HashMap<NodeId, (CircuitLocation, usize)>,
}Expand description
Manages the relations between all different kinds of identifiers used to specify nodes during circuit building and circuit instantiation. Keeps track of [LayerId]s, NodeIds, Labels, LayerVisibilitys, [CircuitLocation]s.
Fields§
§state: CircuitMapState§shreds_in_layer: HashMap<LayerId, Vec<NodeId>>§label_to_shred_id: HashMap<String, NodeId>§layer_label_to_layer_id: HashMap<String, LayerId>§layer_visibility: HashMap<LayerId, LayerVisibility>§node_location: HashMap<NodeId, (CircuitLocation, usize)>Implementations§
Source§impl CircuitMap
impl CircuitMap
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs an empty CircuitMap in a CircuitMapState::UnderConstruction state.
It can receive new data until the Self::freeze method is called which will transition it
to the CircuitMapState::Ready state, at which point it can only be used to answer queries.
Sourcepub fn add_node_id_and_location_num_vars(
&mut self,
node_id: NodeId,
value: (CircuitLocation, usize),
)
pub fn add_node_id_and_location_num_vars( &mut self, node_id: NodeId, value: (CircuitLocation, usize), )
Sourcepub fn insert_shreds_into_input_layer(
&mut self,
input_layer_id: LayerId,
shreds: Vec<NodeId>,
)
pub fn insert_shreds_into_input_layer( &mut self, input_layer_id: LayerId, shreds: Vec<NodeId>, )
Sourcepub fn get_location_num_vars_from_node_id(
&self,
node_id: &NodeId,
) -> Result<&(CircuitLocation, usize)>
pub fn get_location_num_vars_from_node_id( &self, node_id: &NodeId, ) -> Result<&(CircuitLocation, usize)>
Using node_id, retrieves the number of variables and location of this
node in the circuit, or returns an error if node_id is missing.
This method is safe to use in any CircuitMapState.
Sourcepub fn add_input_layer(
&mut self,
layer_id: LayerId,
layer_label: &str,
layer_kind: LayerVisibility,
)
pub fn add_input_layer( &mut self, layer_id: LayerId, layer_label: &str, layer_kind: LayerVisibility, )
Sourcepub fn add_input_shred(&mut self, label: &str, shred_id: NodeId)
pub fn add_input_shred(&mut self, label: &str, shred_id: NodeId)
Adds a new Input Shred labeled label with node ID shred_id.
§Panics
If self is not in a CircuitMapState::UnderConstruction, or if label is already in
use.
§Note
While this method does not panic if shred_id has already been given a different label,
it is considered a semantic error to associate two different labels with the same node, and
Self::freeze may detect it and panic .
Sourcepub fn freeze(self) -> Self
pub fn freeze(self) -> Self
Desctructively mutates self to transition it from a CircuitMapState::UnderConstruction
state to a CircuitMapState::Ready state. As part of the transition, consistency checks are
performed to ensure all internal mappings have all the expected properties.
§Panics
If self is already in a CircuitMapState::Ready state, or if its internal state is
inconsistent.
Sourcepub fn get_node_kind(&self, shred_label: &str) -> Result<LayerVisibility>
pub fn get_node_kind(&self, shred_label: &str) -> Result<LayerVisibility>
Returns the LayerVisibility of the Input Layer that the shred with label shred_label is in,
or an error if the shred_label does not correspond to any input shred.
Sourcepub fn get_node_id(&self, shred_label: &str) -> Result<NodeId>
pub fn get_node_id(&self, shred_label: &str) -> Result<NodeId>
Returns the NodeId of the Input Shred labeled shred_label, or an error if shred_label
does not correspond to any input shred.
Sourcepub fn get_all_input_shred_ids(&self) -> Vec<NodeId>
pub fn get_all_input_shred_ids(&self) -> Vec<NodeId>
Sourcepub fn get_shred_label_from_id(&self, shred_id: NodeId) -> Result<String>
pub fn get_shred_label_from_id(&self, shred_id: NodeId) -> Result<String>
Sourcepub fn get_all_input_layer_ids(&self) -> Vec<LayerId>
pub fn get_all_input_layer_ids(&self) -> Vec<LayerId>
Sourcepub fn get_all_public_input_layer_ids(&self) -> Vec<LayerId>
pub fn get_all_public_input_layer_ids(&self) -> Vec<LayerId>
Sourcepub fn get_input_shreds_from_layer_id(
&self,
layer_id: LayerId,
) -> Result<Vec<NodeId>>
pub fn get_input_shreds_from_layer_id( &self, layer_id: LayerId, ) -> Result<Vec<NodeId>>
Sourcepub fn get_shred_location(
&self,
shred_id: NodeId,
) -> Result<(CircuitLocation, usize)>
pub fn get_shred_location( &self, shred_id: NodeId, ) -> Result<(CircuitLocation, usize)>
Sourcepub fn get_all_committed_layers(&self) -> Vec<LayerId>
pub fn get_all_committed_layers(&self) -> Vec<LayerId>
Returns a vector with all [LayerId]s of the Input Layers with LayerVisibility::Committed visibility.
§Panics
If self is not in CircuitMapState::Ready state.
Sourcepub fn get_layer_id_from_label(&self, layer_label: &str) -> Result<LayerId>
pub fn get_layer_id_from_label(&self, layer_label: &str) -> Result<LayerId>
Returns the layer ID of the input layer with label layer_label, or error if no such layer
exists.
Trait Implementations§
Source§impl Clone for CircuitMap
impl Clone for CircuitMap
Source§fn clone(&self) -> CircuitMap
fn clone(&self) -> CircuitMap
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CircuitMap
impl Debug for CircuitMap
Source§impl Default for CircuitMap
impl Default for CircuitMap
Source§impl<'de> Deserialize<'de> for CircuitMap
impl<'de> Deserialize<'de> for CircuitMap
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CircuitMap
impl PartialEq for CircuitMap
Source§impl Serialize for CircuitMap
impl Serialize for CircuitMap
impl StructuralPartialEq for CircuitMap
Auto Trait Implementations§
impl Freeze for CircuitMap
impl RefUnwindSafe for CircuitMap
impl Send for CircuitMap
impl Sync for CircuitMap
impl Unpin for CircuitMap
impl UnwindSafe for CircuitMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.