pub struct Port {
pub name: String,
pub typ: PortType,
pub lifecycle: Lifecycle,
pub wire_cost: WireCost,
pub constraint: Option<ConstConstraint>,
}Expand description
Descriptor for a single input or output port on a node.
Fields§
§name: String§typ: PortType§lifecycle: Lifecycle§wire_cost: WireCostCost class for input ports. Ignored for output ports.
constraint: Option<ConstConstraint>Optional value contract this wire must satisfy at runtime
(SRD 15 §“Strict Wire Mode”). The compiler uses this to
decide whether to auto-insert a value assertion when the
upstream source can’t statically be proven to deliver a
satisfying value. None = no constraint declared.
Constraints reuse the same vocabulary as
crate::dsl::const_constraints::ConstConstraint — the
difference is just where the value comes from (a literal
for ConstU64, a wire for Slot::Wire).
Implementations§
Source§impl Port
impl Port
pub fn new(name: impl Into<String>, typ: PortType) -> Self
Sourcepub fn with_lifecycle(
name: impl Into<String>,
typ: PortType,
lifecycle: Lifecycle,
) -> Self
pub fn with_lifecycle( name: impl Into<String>, typ: PortType, lifecycle: Lifecycle, ) -> Self
Create a port with explicit lifecycle.
pub fn u64(name: impl Into<String>) -> Self
pub fn f64(name: impl Into<String>) -> Self
pub fn str(name: impl Into<String>) -> Self
pub fn bool(name: impl Into<String>) -> Self
pub fn json(name: impl Into<String>) -> Self
pub fn handle(name: impl Into<String>) -> Self
pub fn vec_f32(name: impl Into<String>) -> Self
pub fn vec_i32(name: impl Into<String>) -> Self
Sourcepub fn init(name: impl Into<String>, typ: PortType) -> Self
pub fn init(name: impl Into<String>, typ: PortType) -> Self
Create an init-time port (frozen at assembly).
Sourcepub fn with_constraint(self, c: ConstConstraint) -> Self
pub fn with_constraint(self, c: ConstConstraint) -> Self
Attach a value constraint. Used by node authors that want to declare “this wire must satisfy X” so strict-wire-mode can auto-insert the right value assertion. See SRD 15 §“Strict Wire Mode”.