Skip to main content

JobHost

Trait JobHost 

Source
pub trait JobHost:
    Send
    + Sync
    + Any
    + Debug {
    // Required method
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn compact_storage(&self) -> Result<(), FnError> { ... }
    fn execute_write_cypher(&self, _cypher: &str) -> Result<(), FnError> { ... }
}
Expand description

Marker trait for the host’s background-job execution facilities.

Concrete hosts (e.g., uni-db’s SchedulerJobHost) implement this and expose typed accessors on the concrete type. Job providers downcast via JobHost::as_any when they need host services like the storage manager, plugin registry, or write-mode inner-query execution.

Mirrors crate::traits::procedure::ProcedureHost — same downcasting pattern, just per-job-context flavor.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Returns the host as a downcastable &dyn Any.

Provided Methods§

Source

fn compact_storage(&self) -> Result<(), FnError>

Trigger a best-effort storage compaction.

The built-in uni.system.compaction job calls this from its execute() body. The default impl is a no-op so test hosts don’t have to implement storage access.

§Errors

Returns FnError if the host’s storage manager surfaces a compaction failure.

Source

fn execute_write_cypher(&self, _cypher: &str) -> Result<(), FnError>

Execute a write-mode Cypher statement against the host.

The built-in uni.system.ttl_sweep job calls this with a MATCH (n) WHERE n.__ttl < timestamp() DETACH DELETE n body. The default impl returns an error so test hosts that don’t wire write-mode Cypher can still load.

§Errors

Returns FnError if the host has not wired write-mode Cypher (default) or if the statement fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§