pub struct PortsIn { /* private fields */ }Expand description
Declared input ports available to a node execution boundary.
Implementations§
Source§impl PortsIn
impl PortsIn
Sourcepub fn new(port_ids: impl Into<Vec<PortId>>) -> Self
pub fn new(port_ids: impl Into<Vec<PortId>>) -> Self
Create input handles with declared port identifiers and no channels.
Sourcepub fn from_handles(
port_ids: impl Into<Vec<PortId>>,
handles: impl Into<Vec<InputPortHandle>>,
) -> Self
pub fn from_handles( port_ids: impl Into<Vec<PortId>>, handles: impl Into<Vec<InputPortHandle>>, ) -> Self
Create input handles from declared ports and connected channel handles.
Sourcepub fn with_metadata_sink(
self,
metadata_sink: Arc<dyn MetadataSink + Send + Sync>,
) -> Self
pub fn with_metadata_sink( self, metadata_sink: Arc<dyn MetadataSink + Send + Sync>, ) -> Self
Attach a metadata sink for receive-side observations.
Sourcepub fn with_node_context(self, context: NodeContext) -> Self
pub fn with_node_context(self, context: NodeContext) -> Self
Attach node context for receive-side queue observations.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Return whether this node currently has no declared inputs.
Sourcepub fn connected_edge_count(&self, port_id: &PortId) -> Option<usize>
pub fn connected_edge_count(&self, port_id: &PortId) -> Option<usize>
Number of connected upstream edges for a declared input port.
Sourcepub fn capacity(&self, port_id: &PortId) -> Option<usize>
pub fn capacity(&self, port_id: &PortId) -> Option<usize>
Capacity of the first connected upstream edge for a declared input port.
Sourcepub fn try_recv(
&mut self,
port_id: &PortId,
) -> Result<Option<PortPacket>, PortRecvError>
pub fn try_recv( &mut self, port_id: &PortId, ) -> Result<Option<PortPacket>, PortRecvError>
Try to receive one packet from a declared input port without blocking.
Returns Ok(None) when the port is declared but no packet is currently
queued. Use Self::recv to wait asynchronously.
§Errors
Returns an error if the port is undeclared or all upstream senders have disconnected.
Sourcepub async fn recv(
&mut self,
port_id: &PortId,
cancellation: &CancellationToken,
) -> Result<Option<PortPacket>, PortRecvError>
pub async fn recv( &mut self, port_id: &PortId, cancellation: &CancellationToken, ) -> Result<Option<PortPacket>, PortRecvError>
Receive one packet from a declared input port, waiting asynchronously.
Returns Ok(None) when the port is declared but has no connected
upstream edges. Connected ports wait until a packet arrives, every
upstream edge disconnects, or cancellation is observed.
§Errors
Returns an error if the port is undeclared, all upstream senders have disconnected, or cancellation is observed.
Sourcepub async fn recv_any(
&mut self,
cancellation: &CancellationToken,
) -> Result<Option<(PortId, PortPacket)>, PortRecvError>
pub async fn recv_any( &mut self, cancellation: &CancellationToken, ) -> Result<Option<(PortId, PortPacket)>, PortRecvError>
Receive one packet from any declared input port, waiting asynchronously.
Returns the port that produced the packet with the packet itself.
Returns Ok(None) when the node has no declared inputs or every input
is closed or disconnected.
§Errors
Returns an error if cancellation is observed while waiting.