HostBridgeHandle

Struct HostBridgeHandle 

Source
pub struct HostBridgeHandle { /* private fields */ }
Expand description

Handle for interacting with a specific host bridge node.

Implementations§

Source§

impl HostBridgeHandle

Source

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

Source

pub fn push_any<T: Any + Send + Sync + 'static>( &self, port: impl AsRef<str>, value: T, ) -> u64

Push any typed payload (auto-wrapped).

Source

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.

Source

pub async fn recv(&self, port: impl AsRef<str>) -> Option<CorrelatedPayload>

Async wait for the next payload on a port.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn drain(&self, port: impl AsRef<str>) -> Vec<CorrelatedPayload>

Drain all pending payloads for the given port.

Source

pub fn drain_serialized( &self, port: impl AsRef<str>, ) -> Result<Vec<HostBridgeSerializedPayload>, NodeError>

Drain and serialize all pending payloads for the given port.

Source

pub fn ports(&self) -> impl Iterator<Item = &str>

Ports supported by this bridge (outgoing from host into the graph).

Source

pub fn outgoing_ports(&self) -> impl Iterator<Item = &str>

Alias for ports() to make direction explicit (host -> graph).

Source

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
Source

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>()? { /* ... */ }
}
Source

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.

Source

pub fn alias(&self) -> &str

Returns the node alias associated with this bridge.

Source

pub fn outgoing_port_type(&self, port: impl AsRef<str>) -> Option<&TypeExpr>

Source

pub fn incoming_port_type(&self, port: impl AsRef<str>) -> Option<&TypeExpr>

Source

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.

Source

pub fn drain_values( &self, port: impl AsRef<str>, ) -> Result<Vec<(u64, Value)>, NodeError>

Drain all pending payloads for port, decoding each into a Value when possible.

Any payload that cannot be represented as a Value produces an error.

Trait Implementations§

Source§

impl Clone for HostBridgeHandle

Source§

fn clone(&self) -> HostBridgeHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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