Struct Runtime

Source
pub struct Runtime<'a, S> { /* private fields */ }
Expand description

This is the Runtime that runs a Flowgraph to completion.

Runtimes are generic over the scheduler used to run the Flowgraph.

Implementations§

Source§

impl Runtime<'_, SmolScheduler>

Source

pub fn new() -> Self

Constructs a new Runtime using SmolScheduler::default() for the Scheduler.

Source

pub fn with_custom_routes(routes: Router) -> Self

Set custom routes for the control port Axum webserver

Source§

impl<'a, S: Scheduler + Sync> Runtime<'a, S>

Source

pub fn with_scheduler(scheduler: S) -> Self

Create a Runtime with a given Scheduler

Source

pub fn with_config(scheduler: S, routes: Router) -> Self

Create runtime with given scheduler and Axum routes

Source

pub fn spawn<T: Send + 'static>( &self, future: impl Future<Output = T> + Send + 'static, ) -> Task<T>

Spawn task on runtime

Source

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

Block thread, waiting for future to complete

Source

pub fn spawn_background<T: Send + 'static>( &self, future: impl Future<Output = T> + Send + 'static, )

Spawn task on runtime in background, detaching the handle

Source

pub fn spawn_blocking<T: Send + 'static>( &self, future: impl Future<Output = T> + Send + 'static, ) -> Task<T>

Spawn a blocking task

This is usually moved in a separate thread.

Source

pub fn spawn_blocking_background<T: Send + 'static>( &self, future: impl Future<Output = T> + Send + 'static, )

Spawn a blocking task in the background

Source

pub async fn start<'b>( &'a self, fg: Flowgraph, ) -> (TaskHandle<'b, Result<Flowgraph, Error>>, FlowgraphHandle)
where 'a: 'b,

Start a Flowgraph on the Runtime

Returns, once the flowgraph is constructed and running.

Source

pub fn start_sync( &self, fg: Flowgraph, ) -> (TaskHandle<'_, Result<Flowgraph, Error>>, FlowgraphHandle)

Start a Flowgraph on the Runtime

Blocks until the flowgraph is constructed and running.

Source

pub fn run(&self, fg: Flowgraph) -> Result<Flowgraph, Error>

Start a Flowgraph on the Runtime and block until it terminates.

Source

pub async fn run_async(&self, fg: Flowgraph) -> Result<Flowgraph, Error>

Start a Flowgraph on the Runtime and await its termination.

Source

pub fn scheduler(&self) -> S

Get the Scheduler that is associated with the Runtime.

Source

pub fn handle(&self) -> RuntimeHandle

Get the RuntimeHandle

Trait Implementations§

Source§

impl Default for Runtime<'_, SmolScheduler>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S> Drop for Runtime<'_, S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for Runtime<'a, S>
where S: Freeze,

§

impl<'a, S> !RefUnwindSafe for Runtime<'a, S>

§

impl<'a, S> Send for Runtime<'a, S>
where S: Send,

§

impl<'a, S> Sync for Runtime<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for Runtime<'a, S>
where S: Unpin,

§

impl<'a, S> !UnwindSafe for Runtime<'a, S>

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

Source§

type Output = T

Should always be Self
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.
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
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,