Skip to main content

RuntimeBridge

Struct RuntimeBridge 

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

Worker thread + private current-thread Tokio runtime used to drive async work off the caller’s runtime.

See the crate-level docs for the design rationale. Construct with RuntimeBridge::new; submit work with RuntimeBridge::block_on.

Implementations§

Source§

impl RuntimeBridge

Source

pub fn new() -> Result<Self>

Spawn a worker thread with a private current-thread Tokio runtime.

Returns the worker’s io::Error if the OS refuses the thread spawn. The thread name is heddle-runtime-bridge so it’s identifiable in stack traces and process listings; pick a more specific wrapper at the call site if you need per-consumer naming.

Source

pub fn with_thread_name(thread_name: impl Into<String>) -> Result<Self>

Same as RuntimeBridge::new but uses a custom worker thread name.

Source

pub fn block_on<F, T>(&self, future: F) -> Result<T, BridgeError>
where F: Future<Output = T> + Send + 'static, T: Send + 'static,

Run future on the worker’s runtime and block the caller until it completes, returning the future’s output or a BridgeError when the worker cannot deliver a reply.

future must be Send + 'static; compose it from owned data (Arc clones, owned String keys, serialized bodies), not borrows of &self.

§Errors
  • BridgeError::WorkerDead when the worker thread has terminated (its receive channel was dropped). Subsequent calls will keep returning this error; the bridge cannot recover.
  • BridgeError::ResponseLost when the worker accepted the task but no reply arrived — the future panicked, or the worker’s runtime was dropped while the task was in flight. The bridge itself remains usable; other in-flight callers are unaffected.

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