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>,
    pub accepts_any_type: bool,
}
Expand description

Descriptor for a single input or output port on a node.

Fields§

§name: String

The port’s name, as bindings and diagnostics refer to it.

§typ: PortType

The port’s declared type.

§lifecycle: Lifecycle

When the port’s value changes: per cycle, at init, or as configuration.

§wire_cost: WireCost

Cost class for input ports. Ignored for output ports.

§constraint: Option<ConstConstraint>

Optional value contract this wire must satisfy at runtime (graph_compiler.md §2, strict-wire assertions). 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: bool

Whether 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 flag is per port rather than per node or per node name: 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

Source

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

A cycle-lifecycle port of the given type with no constraint.

Source

pub fn any_type(self) -> Self

This port, taking the wire as it is whatever its type. See Self::accepts_any_type.

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

A u64 port.

Source

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

An f64 port.

Source

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

A string port.

Source

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

A boolean port.

Source

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

A JSON port.

Source

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

A handle port.

Source

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

An f32 vector port.

Source

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

An i32 vector port.

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 graph_compiler.md §2.

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) -> Self

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more