pub struct Port {
pub name: String,
pub typ: PortType,
pub lifecycle: Lifecycle,
pub wire_cost: WireCost,
pub constraint: Option<ConstConstraint>,
pub accepts_any_type: bool,
}Expand description
Descriptor for a single input or output port on a node.
Fields§
§name: StringThe port’s name, as bindings and diagnostics refer to it.
typ: PortTypeThe port’s declared type.
lifecycle: LifecycleWhen the port’s value changes: per cycle, at init, or as configuration.
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).
accepts_any_type: boolWhether this port takes the wire’s value as it is, whatever
type the wire carries — in which case Self::typ is a
nominal placeholder and the assembler inserts no adapter into
this port.
The one shape that needs it is an element of a &[Value]
variadic: the node inspects the Value variant itself, so
converting the wire to the port’s declared type would change
what the node sees — json_array(cycle) would hold the text
of a number rather than the number. A plain Value argument
does not need it, because the assembler resolves that port’s
type from its wire and hands it to the constructor.
The assembler used to decide this from a list of thirteen node
names, which was both a name-keyed table and the wrong
granularity: pick’s selector wires must be Bool while its
value wires are polymorphic, and one flag per node cannot say
that.
Implementations§
Source§impl Port
impl Port
Sourcepub fn new(name: impl Into<String>, typ: PortType) -> Self
pub fn new(name: impl Into<String>, typ: PortType) -> Self
A cycle-lifecycle port of the given type with no constraint.
Sourcepub fn any_type(self) -> Self
pub fn any_type(self) -> Self
This port, taking the wire as it is whatever its type. See
Self::accepts_any_type.
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.
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”.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Port
impl RefUnwindSafe for Port
impl Send for Port
impl Sync for Port
impl Unpin for Port
impl UnsafeUnpin for Port
impl UnwindSafe for Port
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more