pub struct VibeEngine {
pub ctx: Arc<VibeEngineContext>,
/* private fields */
}Expand description
Main entry point for creating and driving a vibe-ready runtime. Main runtime facade for task execution, logging, and SDK context access.
Fields§
§ctx: Arc<VibeEngineContext>Shared engine context for advanced integrations that need low-level clients.
Implementations§
Source§impl VibeEngine
impl VibeEngine
Sourcepub fn capabilities(&self) -> VibeCapabilities
pub fn capabilities(&self) -> VibeCapabilities
Returns compile-time capabilities enabled for this crate build.
§Returns
A VibeCapabilities snapshot describing enabled storage, logging,
and platform capabilities.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
let capabilities = engine.capabilities();
assert_eq!(capabilities.log_store, cfg!(feature = "log-diesel"));Sourcepub fn state(&self) -> VibeEngineState
pub fn state(&self) -> VibeEngineState
Returns the current engine lifecycle state.
§Returns
A VibeEngineState value such as VibeEngineState::Running or
VibeEngineState::Closed.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeEngineState, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
assert_eq!(engine.state(), VibeEngineState::Running);Sourcepub fn executor(&self) -> VibeEngineExecutor
pub fn executor(&self) -> VibeEngineExecutor
Clones the engine executor for advanced task and callback integrations.
§Returns
A cheap clone of VibeEngineExecutor sharing the engine runtime.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
let executor = engine.executor();
executor.post(async {})?;Sourcepub fn store(&self) -> VibeKvStore
pub fn store(&self) -> VibeKvStore
Creates a high-level key-value store facade bound to this engine.
§Returns
A VibeKvStore that performs blocking-friendly operations through
the engine executor.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
let store = engine.store();
store.set_str("theme", "dark")?;Sourcepub fn invoke<T, F>(&self, future: T) -> Result<F, VibeEngineError>
pub fn invoke<T, F>(&self, future: T) -> Result<F, VibeEngineError>
Runs a future on the engine runtime and waits for its result.
Use this for short async operations where the caller needs the return value synchronously.
§Returns
Ok(F) with the future output, or VibeEngineError if the engine is
not running or the task cannot be delivered.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
let answer = engine.invoke(async { 42 })?;
assert_eq!(answer, 42);Sourcepub fn post<T>(&self, future: T)
pub fn post<T>(&self, future: T)
Posts a fire-and-forget future to the engine runtime.
The method logs failures instead of returning them, making it suitable for background work where the caller does not need a result.
§Returns
This method returns (); delivery errors are written to the SDK log.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
engine.post(async {
// perform background work here
});Sourcepub fn cb_pool_once<F, R>(&self, cb: F) -> impl FnOnce(R)
pub fn cb_pool_once<F, R>(&self, cb: F) -> impl FnOnce(R)
Wraps a one-argument callback so it runs on the engine callback pool.
§Returns
A FnOnce(R) wrapper that schedules cb on the callback thread pool.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
let callback = engine.cb_pool_once(|value: i32| assert_eq!(value, 7));
callback(7);Sourcepub fn cb_pool_once2<F, R1, R2>(&self, cb: F) -> impl FnOnce(R1, R2)
pub fn cb_pool_once2<F, R1, R2>(&self, cb: F) -> impl FnOnce(R1, R2)
Wraps a two-argument callback so it runs on the engine callback pool.
§Returns
A FnOnce(R1, R2) wrapper that schedules cb on the callback thread pool.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
let callback = engine.cb_pool_once2(|left: i32, right: i32| assert_eq!(left + right, 3));
callback(1, 2);Source§impl VibeEngine
impl VibeEngine
Sourcepub fn post_with_priority<F>(
&self,
name: impl Into<String>,
priority: VibeTaskPriority,
future: F,
) -> Result<VibeTaskHandle, VibeEngineError>
pub fn post_with_priority<F>( &self, name: impl Into<String>, priority: VibeTaskPriority, future: F, ) -> Result<VibeTaskHandle, VibeEngineError>
Posts a future to a dedicated priority lane.
Tasks submitted to a higher priority lane run before lower-priority
tasks queued at the same time. Returns a VibeTaskHandle that can
be cancelled or awaited.
Sourcepub fn schedule_after<F, Fut>(
&self,
name: impl Into<String>,
delay: Duration,
builder: F,
) -> Result<VibeTaskHandle, VibeEngineError>
pub fn schedule_after<F, Fut>( &self, name: impl Into<String>, delay: Duration, builder: F, ) -> Result<VibeTaskHandle, VibeEngineError>
Schedule a one-shot task to run after delay.
The builder receives a VibeCancellationToken so the user task can
abort cooperatively when the handle is cancelled.
Sourcepub fn schedule_every<F, Fut>(
&self,
name: impl Into<String>,
period: Duration,
builder: F,
) -> Result<VibeTaskHandle, VibeEngineError>
pub fn schedule_every<F, Fut>( &self, name: impl Into<String>, period: Duration, builder: F, ) -> Result<VibeTaskHandle, VibeEngineError>
Schedule a periodic task. The builder is invoked once every period
until the returned handle is cancelled or the engine is destroyed.
Sourcepub fn tasks(&self) -> VibeTaskPanel
pub fn tasks(&self) -> VibeTaskPanel
Diagnostic panel exposing live snapshots of scheduler-tracked tasks.
Source§impl VibeEngine
impl VibeEngine
Sourcepub fn create(config: VibeEngineConfig) -> Result<Self, VibeEngineError>
pub fn create(config: VibeEngineConfig) -> Result<Self, VibeEngineError>
Creates an engine with a Tokio runtime owned by vibe-ready.
§Returns
Ok(VibeEngine) when configuration is valid and storage/logging
backends open successfully, otherwise VibeEngineError.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().app_name("demo").build())?;
engine.destroy_with_timeout(std::time::Duration::from_secs(1))?;Sourcepub fn create_with_runtime_handle(
config: VibeEngineConfig,
runtime_handle: Handle,
) -> Result<Self, VibeEngineError>
pub fn create_with_runtime_handle( config: VibeEngineConfig, runtime_handle: Handle, ) -> Result<Self, VibeEngineError>
Creates an engine using a Tokio runtime owned by the host application.
The host runtime must stay alive for the lifetime of the engine. Destroying the engine closes vibe-ready resources, but does not shut down this runtime.
§Returns
Ok(VibeEngine) bound to runtime_handle, or VibeEngineError if
validation or backend initialization fails.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let runtime = tokio::runtime::Runtime::new().expect("create runtime");
let engine = VibeEngine::create_with_runtime_handle(
VibeEngineConfig::builder().app_name("hosted").build(),
runtime.handle().clone(),
)?;
engine.destroy_with_timeout(std::time::Duration::from_secs(1))?;Sourcepub fn destroy_with_timeout(
&self,
timeout: Duration,
) -> Result<(), VibeEngineError>
pub fn destroy_with_timeout( &self, timeout: Duration, ) -> Result<(), VibeEngineError>
Destroys the engine and waits up to timeout for resources to close.
§Returns
Ok(()) when shutdown finishes or the engine is already closed;
VibeEngineError on timeout, runtime, or backend close failures.
§Examples
use std::time::Duration;
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
engine.destroy_with_timeout(Duration::from_secs(2))?;Sourcepub fn destroy<CB>(&self, cb: CB)
pub fn destroy<CB>(&self, cb: CB)
Destroys the engine using the default timeout and reports through a callback.
§Returns
This method returns () immediately after invoking cb on the callback
pool with Result<(), VibeEngineError>.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
engine.destroy(|result| {
let _ = result;
});Source§impl VibeEngine
impl VibeEngine
Sourcepub fn insert_log(
&self,
should_output_log: bool,
level: LogLevel,
tag: String,
content: String,
)
pub fn insert_log( &self, should_output_log: bool, level: LogLevel, tag: String, content: String, )
Inserts a log record into the configured log backend.
§Returns
This method returns (); backend write failures are handled by the log
subsystem.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeLogLevel, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
engine.insert_log(true, VibeLogLevel::Info, "startup".into(), "ready".into());Source§impl VibeEngine
impl VibeEngine
Sourcepub fn set_log_listener(&self, listener: Option<LogListener>)
pub fn set_log_listener(&self, listener: Option<LogListener>)
Sets or clears the listener that receives emitted log entries.
§Returns
This method returns () and schedules listener installation on the
engine runtime.
§Examples
use vibe_ready::{VibeEngine, VibeEngineConfig, VibeResult};
let engine = VibeEngine::create(VibeEngineConfig::builder().build())?;
engine.set_log_listener(Some(Box::new(|info| {
let _ = info;
})));
engine.set_log_listener(None);Auto Trait Implementations§
impl !RefUnwindSafe for VibeEngine
impl !UnwindSafe for VibeEngine
impl Freeze for VibeEngine
impl Send for VibeEngine
impl Sync for VibeEngine
impl Unpin for VibeEngine
impl UnsafeUnpin for VibeEngine
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more