pub struct HostBridgeHandle { /* private fields */ }Expand description
Handle for interacting with a specific host bridge node.
Implementations§
Source§impl HostBridgeHandle
impl HostBridgeHandle
Sourcepub fn push(
&self,
port: impl AsRef<str>,
payload: EdgePayload,
correlation_id: Option<u64>,
) -> u64
pub fn push( &self, port: impl AsRef<str>, payload: EdgePayload, correlation_id: Option<u64>, ) -> u64
Push a payload for a given output port on the bridge (host -> graph).
Sourcepub fn push_any<T: Any + Send + Sync + 'static>(
&self,
port: impl AsRef<str>,
value: T,
) -> u64
pub fn push_any<T: Any + Send + Sync + 'static>( &self, port: impl AsRef<str>, value: T, ) -> u64
Push any typed payload (auto-wrapped).
Sourcepub fn push_serialized(
&self,
port: impl AsRef<str>,
payload: HostBridgeSerialized,
correlation_id: Option<u64>,
) -> Result<u64, NodeError>
pub fn push_serialized( &self, port: impl AsRef<str>, payload: HostBridgeSerialized, correlation_id: Option<u64>, ) -> Result<u64, NodeError>
Push a serialized payload, decoding it into a runtime payload first.
Sourcepub async fn recv(&self, port: impl AsRef<str>) -> Option<CorrelatedPayload>
pub async fn recv(&self, port: impl AsRef<str>) -> Option<CorrelatedPayload>
Async wait for the next payload on a port.
Sourcepub async fn recv_serialized(
&self,
port: impl AsRef<str>,
) -> Result<Option<HostBridgeSerializedPayload>, NodeError>
pub async fn recv_serialized( &self, port: impl AsRef<str>, ) -> Result<Option<HostBridgeSerializedPayload>, NodeError>
Async wait for the next payload on a port and serialize it.
Sourcepub fn pull_any<T: Any + Clone>(&self, port: impl AsRef<str>) -> Option<T>
pub fn pull_any<T: Any + Clone>(&self, port: impl AsRef<str>) -> Option<T>
Pop and downcast a single payload from the outbound queue for a port.
Sourcepub fn try_pop(&self, port: impl AsRef<str>) -> Option<CorrelatedPayload>
pub fn try_pop(&self, port: impl AsRef<str>) -> Option<CorrelatedPayload>
Try to pop a single payload emitted by the graph on the given port.
Sourcepub fn try_pop_serialized(
&self,
port: impl AsRef<str>,
) -> Result<Option<HostBridgeSerializedPayload>, NodeError>
pub fn try_pop_serialized( &self, port: impl AsRef<str>, ) -> Result<Option<HostBridgeSerializedPayload>, NodeError>
Try to pop and serialize a single payload emitted by the graph.
Sourcepub fn drain(&self, port: impl AsRef<str>) -> Vec<CorrelatedPayload>
pub fn drain(&self, port: impl AsRef<str>) -> Vec<CorrelatedPayload>
Drain all pending payloads for the given port.
Sourcepub fn drain_serialized(
&self,
port: impl AsRef<str>,
) -> Result<Vec<HostBridgeSerializedPayload>, NodeError>
pub fn drain_serialized( &self, port: impl AsRef<str>, ) -> Result<Vec<HostBridgeSerializedPayload>, NodeError>
Drain and serialize all pending payloads for the given port.
Sourcepub fn ports(&self) -> impl Iterator<Item = &str>
pub fn ports(&self) -> impl Iterator<Item = &str>
Ports supported by this bridge (outgoing from host into the graph).
Sourcepub fn outgoing_ports(&self) -> impl Iterator<Item = &str>
pub fn outgoing_ports(&self) -> impl Iterator<Item = &str>
Alias for ports() to make direction explicit (host -> graph).
Sourcepub fn incoming_port_names(&self) -> Vec<String>
pub fn incoming_port_names(&self) -> Vec<String>
Return a snapshot of known graph->host port names.
This uses both:
- inferred port types from the planner (preferred)
- any ports that have appeared in the outbound queues
Sourcepub fn incoming_ports(&self) -> HostPortOwnedIter<'_> ⓘ
pub fn incoming_ports(&self) -> HostPortOwnedIter<'_> ⓘ
Iterate all known graph->host ports as HostPortOwned values.
This is the ergonomic path for host consumers:
for port in host.incoming_ports().filter(|p| p.can_type_to::<Value>()) {
if let Some((_corr, value)) = port.try_pop::<Value>()? { /* ... */ }
}Sourcepub fn iter_ports<'a>(&'a self, ports: &'a [String]) -> HostPorts<'a> ⓘ
pub fn iter_ports<'a>(&'a self, ports: &'a [String]) -> HostPorts<'a> ⓘ
Iterate over a provided list of graph->host port names as “typed ports” that can be filtered and popped in an idiomatic Rust style.
pub fn outgoing_port_type(&self, port: impl AsRef<str>) -> Option<&TypeExpr>
pub fn incoming_port_type(&self, port: impl AsRef<str>) -> Option<&TypeExpr>
Sourcepub fn try_pop_value(
&self,
port: impl AsRef<str>,
) -> Result<Option<(u64, Value)>, NodeError>
pub fn try_pop_value( &self, port: impl AsRef<str>, ) -> Result<Option<(u64, Value)>, NodeError>
Try to pop a single payload for port and decode it into a Value when possible,
without going through JSON string serialization.
This is intended for “non-image” / structured outputs that hosts want to sample cheaply.
If the payload is not value-like (e.g. an image payload stored in Any), this returns an error.
Trait Implementations§
Source§impl Clone for HostBridgeHandle
impl Clone for HostBridgeHandle
Source§fn clone(&self) -> HostBridgeHandle
fn clone(&self) -> HostBridgeHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for HostBridgeHandle
impl RefUnwindSafe for HostBridgeHandle
impl Send for HostBridgeHandle
impl Sync for HostBridgeHandle
impl Unpin for HostBridgeHandle
impl UnwindSafe for HostBridgeHandle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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