Skip to main content

Engine

Struct Engine 

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

The main engine driving T-minus coordination.

Implementations§

Source§

impl Engine

Source

pub fn new(db_path: &Path) -> Result<Self, TMinusError>

Create a new engine with SQLite storage at the given path.

Source

pub fn in_memory() -> Result<Self, TMinusError>

Create an in-memory engine (for testing).

Source

pub fn schedule_event( &mut self, kind: EventKind, scheduled_at: DateTime<Utc>, t_minus: Duration, organizer: AgentId, attendees: Vec<AgentId>, quorum: usize, payload: Value, ) -> Result<TMinusEvent, TMinusError>

Schedule a new event.

Source

pub fn confirm( &mut self, event_id: Uuid, agent_id: &AgentId, ) -> Result<TMinusEvent, TMinusError>

Confirm an agent’s attendance.

Source

pub fn defer( &mut self, event_id: Uuid, agent_id: &AgentId, duration: Duration, ) -> Result<TMinusEvent, TMinusError>

Defer an agent’s response with a requested delay.

Source

pub fn mark_missed( &mut self, event_id: Uuid, ) -> Result<TMinusEvent, TMinusError>

Mark all pending attendees of an event as missed.

Source

pub fn list_events(&self) -> Result<Vec<TMinusEvent>, TMinusError>

Get all events.

Source

pub fn get_event(&self, id: Uuid) -> Result<Option<TMinusEvent>, TMinusError>

Get a specific event.

Source

pub fn remove_event(&mut self, id: Uuid) -> Result<bool, TMinusError>

Remove a fired/missed event.

Source

pub fn create_campaign(&mut self, name: String) -> Result<Campaign, TMinusError>

Create a new campaign.

Source

pub fn campaign_add_event( &mut self, campaign_id: Uuid, event_id: Uuid, ) -> Result<Campaign, TMinusError>

Add an event to a campaign.

Add a dependency edge between two events in a campaign.

Source

pub fn campaign_execution_order( &self, campaign_id: Uuid, ) -> Result<Vec<Uuid>, TMinusError>

Get campaign execution order (topological sort).

Source

pub fn list_campaigns(&self) -> Result<Vec<Campaign>, TMinusError>

List all campaigns.

Source

pub fn get_campaign(&self, id: Uuid) -> Result<Option<Campaign>, TMinusError>

Get a specific campaign.

Source

pub fn tick(&mut self, now: DateTime<Utc>) -> Result<TickResult, TMinusError>

Process the current moment: fire events that reached quorum, mark missed, handle deferrals.

Source

pub fn apply_deferral_cascade( &mut self, event_id: Uuid, ) -> Result<Option<TMinusEvent>, TMinusError>

Process a deferral cascade: when an agent defers, push the event’s t_minus forward. Returns the updated event if the max deferral is applied.

Auto Trait Implementations§

§

impl !Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl !Sync for Engine

§

impl !UnwindSafe for Engine

§

impl Send for Engine

§

impl Unpin for Engine

§

impl UnsafeUnpin for Engine

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.