pub struct Hugr { /* private fields */ }
Expand description
The Hugr data structure.
Implementations§
Source§impl Hugr
impl Hugr
Sourcepub fn into_region_portgraph(
self,
parent: Node,
) -> FlatRegion<'static, MultiPortGraph>
pub fn into_region_portgraph( self, parent: Node, ) -> FlatRegion<'static, MultiPortGraph>
Consumes the HUGR and return a flat portgraph view of the region rooted
at parent
.
Source§impl Hugr
Public API for HUGRs.
impl Hugr
Public API for HUGRs.
Sourcepub fn new_with_entrypoint(
entrypoint_op: impl Into<OpType>,
) -> Result<Self, HugrError>
pub fn new_with_entrypoint( entrypoint_op: impl Into<OpType>, ) -> Result<Self, HugrError>
Create a new Hugr, with a given entrypoint operation.
If the optype is OpType::Module
, the HUGR module root will match the
entrypoint node. Otherwise, the entrypoint will be a descendent of the a
module initialized at the node hierarchy root. The specific HUGR created
depends on the operation type.
§Error
Returns HugrError::UnsupportedEntrypoint
if the entrypoint operation
requires additional context to be defined. This is the case for
OpType::Case
, OpType::DataflowBlock
, and OpType::ExitBlock
since they are context-specific definitions.
Sourcepub fn with_capacity(
entrypoint_op: impl Into<OpType>,
nodes: usize,
ports: usize,
) -> Result<Self, HugrError>
pub fn with_capacity( entrypoint_op: impl Into<OpType>, nodes: usize, ports: usize, ) -> Result<Self, HugrError>
Create a new Hugr, with a given entrypoint operation and preallocated capacity.
If the optype is OpType::Module
, the HUGR module root will match the
entrypoint node. Otherwise, the entrypoint will be a child of the a
module initialized at the node hierarchy root. The specific HUGR created
depends on the operation type.
§Error
Returns HugrError::UnsupportedEntrypoint
if the entrypoint operation
requires additional context to be defined. This is the case for
OpType::Case
, OpType::DataflowBlock
, and OpType::ExitBlock
since they are context-specific definitions.
Sourcepub fn reserve(&mut self, nodes: usize, links: usize)
pub fn reserve(&mut self, nodes: usize, links: usize)
Reserves enough capacity to insert at least the given number of additional nodes and links.
This method does not take into account already allocated free space left after node removals, and may overallocate capacity.
Sourcepub fn load(
reader: impl BufRead,
extensions: Option<&ExtensionRegistry>,
) -> Result<Self, EnvelopeError>
pub fn load( reader: impl BufRead, extensions: Option<&ExtensionRegistry>, ) -> Result<Self, EnvelopeError>
Read a HUGR from an Envelope.
To load a HUGR, all the extensions used in its definition must be
available. The Envelope may include some of the extensions, but any
additional extensions must be provided in the extensions
parameter. If
extensions
is None
, the default crate::std_extensions::STD_REG
is used.
Sourcepub fn load_str(
envelope: impl AsRef<str>,
extensions: Option<&ExtensionRegistry>,
) -> Result<Self, EnvelopeError>
pub fn load_str( envelope: impl AsRef<str>, extensions: Option<&ExtensionRegistry>, ) -> Result<Self, EnvelopeError>
Read a HUGR from an Envelope encoded in a string.
Note that not all Envelopes are valid strings. In the general case,
it is recommended to use Hugr::load
with a bytearray instead.
To load a HUGR, all the extensions used in its definition must be
available. The Envelope may include some of the extensions, but any
additional extensions must be provided in the extensions
parameter. If
extensions
is None
, the default crate::std_extensions::STD_REG
is used.
Sourcepub fn store(
&self,
writer: impl Write,
config: EnvelopeConfig,
) -> Result<(), EnvelopeError>
pub fn store( &self, writer: impl Write, config: EnvelopeConfig, ) -> Result<(), EnvelopeError>
Store the HUGR in an Envelope.
The Envelope will not include any extension definition, and will require
an adequate ExtensionRegistry
to be loaded (see Hugr::load
).
Use Hugr::store_with_exts
to include additional extensions in the
Envelope.
Sourcepub fn store_with_exts(
&self,
writer: impl Write,
config: EnvelopeConfig,
extensions: &ExtensionRegistry,
) -> Result<(), EnvelopeError>
pub fn store_with_exts( &self, writer: impl Write, config: EnvelopeConfig, extensions: &ExtensionRegistry, ) -> Result<(), EnvelopeError>
Store the HUGR in an Envelope.
The Envelope will embed the definitions of the extensions in the
extensions
registry. Any other extension used in the HUGR definition
must be passed to Hugr::load
to load back the HUGR.
Sourcepub fn store_str(&self, config: EnvelopeConfig) -> Result<String, EnvelopeError>
pub fn store_str(&self, config: EnvelopeConfig) -> Result<String, EnvelopeError>
Store the HUGR in an Envelope encoded in a string.
Note that not all Envelopes are valid strings. In the general case,
it is recommended to use Hugr::store
with a bytearray instead.
See EnvelopeFormat::ascii_printable
.
The Envelope will not include any extension definition, and will require
an adequate ExtensionRegistry
to be loaded (see Hugr::load_str
).
Use Hugr::store_str_with_exts
to include additional extensions in the
Envelope.
Sourcepub fn store_str_with_exts(
&self,
config: EnvelopeConfig,
extensions: &ExtensionRegistry,
) -> Result<String, EnvelopeError>
pub fn store_str_with_exts( &self, config: EnvelopeConfig, extensions: &ExtensionRegistry, ) -> Result<String, EnvelopeError>
Store the HUGR in an Envelope encoded in a string.
Note that not all Envelopes are valid strings. In the general case,
it is recommended to use Hugr::store_str
with a bytearray instead.
See EnvelopeFormat::ascii_printable
.
The Envelope will embed the definitions of the extensions in the
extensions
registry. Any other extension used in the HUGR definition
must be passed to Hugr::load_str
to load back the HUGR.
Sourcepub fn resolve_extension_defs(
&mut self,
extensions: &ExtensionRegistry,
) -> Result<(), ExtensionResolutionError>
pub fn resolve_extension_defs( &mut self, extensions: &ExtensionRegistry, ) -> Result<(), ExtensionResolutionError>
Given a Hugr that has been deserialized, collect all extensions used to
define the HUGR while resolving all OpType::OpaqueOp
operations into
OpType::ExtensionOp
s and updating the extension pointer in all
internal crate::types::CustomType
s to point to the extensions in the
register.
When listing “used extensions” we only care about definitional extension requirements, i.e., the operations and types that are required to define the HUGR nodes and wire types. This is computed from the union of all extension required across the HUGR.
Updates the internal extension registry with the extensions used in the definition.
§Parameters
extensions
: The extension set considered when resolving opaque operations and types. The original Hugr’s internal extension registry is ignored and replaced with the newly computed one.
§Errors
- If an opaque operation cannot be resolved to an extension operation.
- If an extension operation references an extension that is missing from the registry.
- If a custom type references an extension that is missing from the registry.
Source§impl Hugr
Internal API for HUGRs, not intended for use by users.
impl Hugr
Internal API for HUGRs, not intended for use by users.
Sourcepub fn canonicalize_nodes(&mut self, rekey: impl FnMut(Node, Node))
pub fn canonicalize_nodes(&mut self, rekey: impl FnMut(Node, Node))
Compact the nodes indices of the hugr to be contiguous, and order them as a breadth-first traversal of the hierarchy.
The rekey function is called for each moved node with the old and new indices.
After this operation, a serialization and deserialization of the Hugr is guaranteed to preserve the indices.
Trait Implementations§
Source§impl<'de> DeserializeAs<'de, Hugr> for AsStringEnvelope
impl<'de> DeserializeAs<'de, Hugr> for AsStringEnvelope
Source§fn deserialize_as<D>(deserializer: D) -> Result<Hugr, D::Error>where
D: Deserializer<'de>,
fn deserialize_as<D>(deserializer: D) -> Result<Hugr, D::Error>where
D: Deserializer<'de>,
Source§impl HugrInternals for Hugr
impl HugrInternals for Hugr
Source§type RegionPortgraph<'p> = &'p MultiPortGraph
where
Self: 'p
type RegionPortgraph<'p> = &'p MultiPortGraph where Self: 'p
HugrInternals::region_portgraph
.Source§type RegionPortgraphNodes = DefaultPGNodeMap
type RegionPortgraphNodes = DefaultPGNodeMap
HugrInternals::region_portgraph
.Source§fn region_portgraph(
&self,
parent: Self::Node,
) -> (FlatRegion<'_, Self::RegionPortgraph<'_>>, Self::RegionPortgraphNodes)
fn region_portgraph( &self, parent: Self::Node, ) -> (FlatRegion<'_, Self::RegionPortgraph<'_>>, Self::RegionPortgraphNodes)
Source§fn node_metadata_map(&self, node: Self::Node) -> &NodeMetadataMap
fn node_metadata_map(&self, node: Self::Node) -> &NodeMetadataMap
Source§impl HugrMut for Hugr
Impl for non-wrapped Hugrs. Overwrites the recursive default-impls to directly use the hugr.
impl HugrMut for Hugr
Impl for non-wrapped Hugrs. Overwrites the recursive default-impls to directly use the hugr.
Source§fn set_entrypoint(&mut self, root: Node)
fn set_entrypoint(&mut self, root: Node)
Source§fn get_metadata_mut(
&mut self,
node: Self::Node,
key: impl AsRef<str>,
) -> &mut NodeMetadata
fn get_metadata_mut( &mut self, node: Self::Node, key: impl AsRef<str>, ) -> &mut NodeMetadata
Source§fn set_metadata(
&mut self,
node: Self::Node,
key: impl AsRef<str>,
metadata: impl Into<NodeMetadata>,
)
fn set_metadata( &mut self, node: Self::Node, key: impl AsRef<str>, metadata: impl Into<NodeMetadata>, )
Source§fn remove_metadata(&mut self, node: Self::Node, key: impl AsRef<str>)
fn remove_metadata(&mut self, node: Self::Node, key: impl AsRef<str>)
Source§fn add_node_with_parent(
&mut self,
parent: Node,
node: impl Into<OpType>,
) -> Node
fn add_node_with_parent( &mut self, parent: Node, node: impl Into<OpType>, ) -> Node
Source§fn add_node_before(
&mut self,
sibling: Node,
nodetype: impl Into<OpType>,
) -> Node
fn add_node_before( &mut self, sibling: Node, nodetype: impl Into<OpType>, ) -> Node
Source§fn add_node_after(&mut self, sibling: Node, op: impl Into<OpType>) -> Node
fn add_node_after(&mut self, sibling: Node, op: impl Into<OpType>) -> Node
Source§fn remove_node(&mut self, node: Node) -> OpType
fn remove_node(&mut self, node: Node) -> OpType
Self::remove_subtree
. Read moreSource§fn remove_subtree(&mut self, node: Node)
fn remove_subtree(&mut self, node: Node)
Source§fn connect(
&mut self,
src: Node,
src_port: impl Into<OutgoingPort>,
dst: Node,
dst_port: impl Into<IncomingPort>,
)
fn connect( &mut self, src: Node, src_port: impl Into<OutgoingPort>, dst: Node, dst_port: impl Into<IncomingPort>, )
Source§fn disconnect(&mut self, node: Node, port: impl Into<Port>)
fn disconnect(&mut self, node: Node, port: impl Into<Port>)
Source§fn add_other_edge(
&mut self,
src: Node,
dst: Node,
) -> (OutgoingPort, IncomingPort)
fn add_other_edge( &mut self, src: Node, dst: Node, ) -> (OutgoingPort, IncomingPort)
OpTrait::other_input
or OpTrait::other_output
. Read moreSource§fn insert_hugr(
&mut self,
root: Self::Node,
other: Hugr,
) -> InsertionResult<Node, Self::Node>
fn insert_hugr( &mut self, root: Self::Node, other: Hugr, ) -> InsertionResult<Node, Self::Node>
Source§fn insert_from_view<H: HugrView>(
&mut self,
root: Self::Node,
other: &H,
) -> InsertionResult<H::Node, Self::Node>
fn insert_from_view<H: HugrView>( &mut self, root: Self::Node, other: &H, ) -> InsertionResult<H::Node, Self::Node>
Source§fn insert_subgraph<H: HugrView>(
&mut self,
root: Self::Node,
other: &H,
subgraph: &SiblingSubgraph<H::Node>,
) -> HashMap<H::Node, Self::Node>
fn insert_subgraph<H: HugrView>( &mut self, root: Self::Node, other: &H, subgraph: &SiblingSubgraph<H::Node>, ) -> HashMap<H::Node, Self::Node>
Source§fn copy_descendants(
&mut self,
root: Self::Node,
new_parent: Self::Node,
subst: Option<Substitution<'_>>,
) -> BTreeMap<Self::Node, Self::Node>
fn copy_descendants( &mut self, root: Self::Node, new_parent: Self::Node, subst: Option<Substitution<'_>>, ) -> BTreeMap<Self::Node, Self::Node>
root
to under the new_parent
, optionally applying a
Substitution to the OpType
s of the copied nodes. Read moreSource§fn use_extension(&mut self, extension: impl Into<Arc<Extension>>)
fn use_extension(&mut self, extension: impl Into<Arc<Extension>>)
Source§fn use_extensions<Reg>(&mut self, registry: impl IntoIterator<Item = Reg>)where
ExtensionRegistry: Extend<Reg>,
fn use_extensions<Reg>(&mut self, registry: impl IntoIterator<Item = Reg>)where
ExtensionRegistry: Extend<Reg>,
Source§impl HugrMutInternals for Hugr
Impl for non-wrapped Hugrs. Overwrites the recursive default-impls to directly use the hugr.
impl HugrMutInternals for Hugr
Impl for non-wrapped Hugrs. Overwrites the recursive default-impls to directly use the hugr.
Source§fn set_module_root(&mut self, root: Node)
fn set_module_root(&mut self, root: Node)
Source§fn set_num_ports(&mut self, node: Node, incoming: usize, outgoing: usize)
fn set_num_ports(&mut self, node: Node, incoming: usize, outgoing: usize)
PortIndex
. Read moreSource§fn add_ports(
&mut self,
node: Node,
direction: Direction,
amount: isize,
) -> Range<usize>
fn add_ports( &mut self, node: Node, direction: Direction, amount: isize, ) -> Range<usize>
PortIndex
. Read moreSource§fn insert_ports(
&mut self,
node: Node,
direction: Direction,
index: usize,
amount: usize,
) -> Range<usize>
fn insert_ports( &mut self, node: Node, direction: Direction, index: usize, amount: usize, ) -> Range<usize>
amount
new ports for a node, starting at index
. The
direction
parameter specifies whether to add ports to the incoming or
outgoing list. Links from this node are preserved, even when ports are
renumbered by the insertion. Read moreSource§fn move_after_sibling(&mut self, node: Node, after: Node)
fn move_after_sibling(&mut self, node: Node, after: Node)
Source§fn move_before_sibling(&mut self, node: Node, before: Node)
fn move_before_sibling(&mut self, node: Node, before: Node)
Source§fn replace_op(&mut self, node: Node, op: impl Into<OpType>) -> OpType
fn replace_op(&mut self, node: Node, op: impl Into<OpType>) -> OpType
OpType
at node and return the old OpType
.
In general this invalidates the ports, which may need to be resized to
match the OpType
signature. Read moreSource§fn optype_mut(&mut self, node: Node) -> &mut OpType
fn optype_mut(&mut self, node: Node) -> &mut OpType
Source§fn node_metadata_map_mut(&mut self, node: Self::Node) -> &mut NodeMetadataMap
fn node_metadata_map_mut(&mut self, node: Self::Node) -> &mut NodeMetadataMap
Source§fn extensions_mut(&mut self) -> &mut ExtensionRegistry
fn extensions_mut(&mut self) -> &mut ExtensionRegistry
Source§impl HugrView for Hugr
impl HugrView for Hugr
Source§fn entrypoint(&self) -> Self::Node
fn entrypoint(&self) -> Self::Node
Source§fn module_root(&self) -> Self::Node
fn module_root(&self) -> Self::Node
Source§fn contains_node(&self, node: Self::Node) -> bool
fn contains_node(&self, node: Self::Node) -> bool
true
if the node exists in the HUGR.Source§fn num_ports(&self, node: Self::Node, dir: Direction) -> usize
fn num_ports(&self, node: Self::Node, dir: Direction) -> usize
Source§fn nodes(&self) -> impl Iterator<Item = Node> + Clone
fn nodes(&self) -> impl Iterator<Item = Node> + Clone
Source§fn node_ports(
&self,
node: Node,
dir: Direction,
) -> impl Iterator<Item = Port> + Clone
fn node_ports( &self, node: Node, dir: Direction, ) -> impl Iterator<Item = Port> + Clone
Source§fn all_node_ports(&self, node: Node) -> impl Iterator<Item = Port> + Clone
fn all_node_ports(&self, node: Node) -> impl Iterator<Item = Port> + Clone
Source§fn linked_ports(
&self,
node: Node,
port: impl Into<Port>,
) -> impl Iterator<Item = (Node, Port)> + Clone
fn linked_ports( &self, node: Node, port: impl Into<Port>, ) -> impl Iterator<Item = (Node, Port)> + Clone
Source§fn node_connections(
&self,
node: Node,
other: Node,
) -> impl Iterator<Item = [Port; 2]> + Clone
fn node_connections( &self, node: Node, other: Node, ) -> impl Iterator<Item = [Port; 2]> + Clone
Source§fn children(
&self,
node: Self::Node,
) -> impl DoubleEndedIterator<Item = Self::Node> + Clone
fn children( &self, node: Self::Node, ) -> impl DoubleEndedIterator<Item = Self::Node> + Clone
Source§fn descendants(
&self,
node: Self::Node,
) -> impl Iterator<Item = Self::Node> + Clone
fn descendants( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone
Source§fn neighbours(
&self,
node: Node,
dir: Direction,
) -> impl Iterator<Item = Node> + Clone
fn neighbours( &self, node: Node, dir: Direction, ) -> impl Iterator<Item = Node> + Clone
Source§fn all_neighbours(&self, node: Node) -> impl Iterator<Item = Node> + Clone
fn all_neighbours(&self, node: Node) -> impl Iterator<Item = Node> + Clone
node
in sequence.Source§fn mermaid_string_with_config(&self, config: RenderConfig) -> String
fn mermaid_string_with_config(&self, config: RenderConfig) -> String
mermaid_format
insteadSource§fn mermaid_string_with_formatter(
&self,
formatter: MermaidFormatter<'_, Self>,
) -> String
fn mermaid_string_with_formatter( &self, formatter: MermaidFormatter<'_, Self>, ) -> String
MermaidFormatter
formatting options. Read moreSource§fn dot_string(&self) -> Stringwhere
Self: Sized,
fn dot_string(&self) -> Stringwhere
Self: Sized,
Source§fn extensions(&self) -> &ExtensionRegistry
fn extensions(&self) -> &ExtensionRegistry
Source§fn extract_hugr(
&self,
target: Node,
) -> (Hugr, impl ExtractionResult<Node> + 'static)
fn extract_hugr( &self, target: Node, ) -> (Hugr, impl ExtractionResult<Node> + 'static)
Source§fn entrypoint_optype(&self) -> &OpType
fn entrypoint_optype(&self) -> &OpType
Source§fn entrypoint_tag(&self) -> OpTag
fn entrypoint_tag(&self) -> OpTag
HugrView::entrypoint
node operation. Read moreSource§fn with_entrypoint(&self, entrypoint: Self::Node) -> Rerooted<&Self>where
Self: Sized,
fn with_entrypoint(&self, entrypoint: Self::Node) -> Rerooted<&Self>where
Self: Sized,
Source§fn get_metadata(
&self,
node: Self::Node,
key: impl AsRef<str>,
) -> Option<&NodeMetadata>
fn get_metadata( &self, node: Self::Node, key: impl AsRef<str>, ) -> Option<&NodeMetadata>
Source§fn num_inputs(&self, node: Self::Node) -> usize
fn num_inputs(&self, node: Self::Node) -> usize
num_ports
(node, Direction::Incoming)
.Source§fn num_outputs(&self, node: Self::Node) -> usize
fn num_outputs(&self, node: Self::Node) -> usize
num_ports
(node, Direction::Outgoing)
.Source§fn node_outputs(
&self,
node: Self::Node,
) -> impl Iterator<Item = OutgoingPort> + Clone
fn node_outputs( &self, node: Self::Node, ) -> impl Iterator<Item = OutgoingPort> + Clone
node_ports
(node, Direction::Outgoing)
but preserves knowledge that the ports are OutgoingPort
s.Source§fn node_inputs(
&self,
node: Self::Node,
) -> impl Iterator<Item = IncomingPort> + Clone
fn node_inputs( &self, node: Self::Node, ) -> impl Iterator<Item = IncomingPort> + Clone
node_ports
(node, Direction::Incoming)
but preserves knowledge that the ports are IncomingPort
s.Source§fn all_linked_ports(
&self,
node: Self::Node,
dir: Direction,
) -> Either<impl Iterator<Item = (Self::Node, OutgoingPort)>, impl Iterator<Item = (Self::Node, IncomingPort)>> ⓘ
fn all_linked_ports( &self, node: Self::Node, dir: Direction, ) -> Either<impl Iterator<Item = (Self::Node, OutgoingPort)>, impl Iterator<Item = (Self::Node, IncomingPort)>> ⓘ
Source§fn all_linked_outputs(
&self,
node: Self::Node,
) -> impl Iterator<Item = (Self::Node, OutgoingPort)>
fn all_linked_outputs( &self, node: Self::Node, ) -> impl Iterator<Item = (Self::Node, OutgoingPort)>
Source§fn all_linked_inputs(
&self,
node: Self::Node,
) -> impl Iterator<Item = (Self::Node, IncomingPort)>
fn all_linked_inputs( &self, node: Self::Node, ) -> impl Iterator<Item = (Self::Node, IncomingPort)>
Source§fn single_linked_port(
&self,
node: Self::Node,
port: impl Into<Port>,
) -> Option<(Self::Node, Port)>
fn single_linked_port( &self, node: Self::Node, port: impl Into<Port>, ) -> Option<(Self::Node, Port)>
Source§fn single_linked_output(
&self,
node: Self::Node,
port: impl Into<IncomingPort>,
) -> Option<(Self::Node, OutgoingPort)>
fn single_linked_output( &self, node: Self::Node, port: impl Into<IncomingPort>, ) -> Option<(Self::Node, OutgoingPort)>
OutgoingPort
connected to this IncomingPort
, return
it and its node.Source§fn single_linked_input(
&self,
node: Self::Node,
port: impl Into<OutgoingPort>,
) -> Option<(Self::Node, IncomingPort)>
fn single_linked_input( &self, node: Self::Node, port: impl Into<OutgoingPort>, ) -> Option<(Self::Node, IncomingPort)>
IncomingPort
connected to this OutgoingPort
, return
it and its node.Source§fn linked_outputs(
&self,
node: Self::Node,
port: impl Into<IncomingPort>,
) -> impl Iterator<Item = (Self::Node, OutgoingPort)>
fn linked_outputs( &self, node: Self::Node, port: impl Into<IncomingPort>, ) -> impl Iterator<Item = (Self::Node, OutgoingPort)>
linked_ports
but preserves knowledge
that the linked ports are OutgoingPort
s.Source§fn linked_inputs(
&self,
node: Self::Node,
port: impl Into<OutgoingPort>,
) -> impl Iterator<Item = (Self::Node, IncomingPort)>
fn linked_inputs( &self, node: Self::Node, port: impl Into<OutgoingPort>, ) -> impl Iterator<Item = (Self::Node, IncomingPort)>
linked_ports
but preserves knowledge
that the linked ports are IncomingPort
s.Source§fn is_linked(&self, node: Self::Node, port: impl Into<Port>) -> bool
fn is_linked(&self, node: Self::Node, port: impl Into<Port>) -> bool
Source§fn entry_descendants(&self) -> impl Iterator<Item = Self::Node> + Clone
fn entry_descendants(&self) -> impl Iterator<Item = Self::Node> + Clone
Source§fn first_child(&self, node: Self::Node) -> Option<Self::Node>
fn first_child(&self, node: Self::Node) -> Option<Self::Node>
x.children().next()
leaves x borrowed.Source§fn input_neighbours(
&self,
node: Self::Node,
) -> impl Iterator<Item = Self::Node> + Clone
fn input_neighbours( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone
node
.
Shorthand for neighbours
(node, Direction::Incoming)
.Source§fn output_neighbours(
&self,
node: Self::Node,
) -> impl Iterator<Item = Self::Node> + Clone
fn output_neighbours( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Node> + Clone
node
.
Shorthand for neighbours
(node, Direction::Outgoing)
.Source§fn get_io(&self, node: Self::Node) -> Option<[Self::Node; 2]>
fn get_io(&self, node: Self::Node) -> Option<[Self::Node; 2]>
Source§fn inner_function_type(&self) -> Option<Cow<'_, Signature>>
fn inner_function_type(&self) -> Option<Cow<'_, Signature>>
Source§fn poly_func_type(&self) -> Option<PolyFuncType>
fn poly_func_type(&self) -> Option<PolyFuncType>
Source§fn as_petgraph(&self) -> PetgraphWrapper<'_, Self>where
Self: Sized,
fn as_petgraph(&self) -> PetgraphWrapper<'_, Self>where
Self: Sized,
Source§fn mermaid_string(&self) -> String
fn mermaid_string(&self) -> String
Source§fn mermaid_format(&self) -> MermaidFormatter<'_, Self>
fn mermaid_format(&self) -> MermaidFormatter<'_, Self>
Source§fn static_source(&self, node: Self::Node) -> Option<Self::Node>
fn static_source(&self, node: Self::Node) -> Option<Self::Node>
Source§fn static_targets(
&self,
node: Self::Node,
) -> Option<impl Iterator<Item = (Self::Node, IncomingPort)>>
fn static_targets( &self, node: Self::Node, ) -> Option<impl Iterator<Item = (Self::Node, IncomingPort)>>
Source§fn signature(&self, node: Self::Node) -> Option<Cow<'_, Signature>>
fn signature(&self, node: Self::Node) -> Option<Cow<'_, Signature>>
Source§fn value_types(
&self,
node: Self::Node,
dir: Direction,
) -> impl Iterator<Item = (Port, Type)>
fn value_types( &self, node: Self::Node, dir: Direction, ) -> impl Iterator<Item = (Port, Type)>
Source§fn in_value_types(
&self,
node: Self::Node,
) -> impl Iterator<Item = (IncomingPort, Type)>
fn in_value_types( &self, node: Self::Node, ) -> impl Iterator<Item = (IncomingPort, Type)>
Source§fn out_value_types(
&self,
node: Self::Node,
) -> impl Iterator<Item = (OutgoingPort, Type)>
fn out_value_types( &self, node: Self::Node, ) -> impl Iterator<Item = (OutgoingPort, Type)>
Source§impl SerializeAs<Hugr> for AsStringEnvelope
impl SerializeAs<Hugr> for AsStringEnvelope
Source§fn serialize_as<S>(source: &Hugr, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize_as<S>(source: &Hugr, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
impl StructuralPartialEq for Hugr
Auto Trait Implementations§
impl !Freeze for Hugr
impl !RefUnwindSafe for Hugr
impl Send for Hugr
impl Sync for Hugr
impl Unpin for Hugr
impl !UnwindSafe for Hugr
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<H, Handle> RootCheckable<H, Handle> for H
impl<H, Handle> RootCheckable<H, Handle> for H
Source§fn try_into_checked(self) -> Result<RootChecked<H, Handle>, HugrError>
fn try_into_checked(self) -> Result<RootChecked<H, Handle>, HugrError>
Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.