Skip to main content

Port

Struct Port 

Source
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: WireCost

Cost 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

Source

pub fn new(name: impl Into<String>, typ: PortType) -> Self

Source

pub fn with_lifecycle( name: impl Into<String>, typ: PortType, lifecycle: Lifecycle, ) -> Self

Create a port with explicit lifecycle.

Source

pub fn u64(name: impl Into<String>) -> Self

Source

pub fn f64(name: impl Into<String>) -> Self

Source

pub fn str(name: impl Into<String>) -> Self

Source

pub fn bool(name: impl Into<String>) -> Self

Source

pub fn json(name: impl Into<String>) -> Self

Source

pub fn handle(name: impl Into<String>) -> Self

Source

pub fn vec_f32(name: impl Into<String>) -> Self

Source

pub fn vec_i32(name: impl Into<String>) -> Self

Source

pub fn init(name: impl Into<String>, typ: PortType) -> Self

Create an init-time port (frozen at assembly).

Source

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”.

Source

pub fn config(self) -> Self

Mark this port as a config wire (expensive to change).

Source

pub fn with_cost(self, cost: WireCost) -> Self

Set the wire cost directly. Used by the macro to thread Wire::WIRE_COST from the trait through to the slot.

Trait Implementations§

Source§

impl Clone for Port

Source§

fn clone(&self) -> Port

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Port

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.