Skip to main content

State

Trait State 

Source
pub trait State: Sync {
    type Admission: Send + Sync;

    // Required methods
    fn verify(&self) -> Result<(), Problem>;
    fn validate_destination(&self, path: &Path) -> Result<(), Problem>;
    fn reserve(&self, path: &Path) -> Result<(), Problem>;
    fn admit(&self, name: &str) -> Result<Self::Admission, Problem>;
    fn ensure_new(
        &self,
        admission: &Self::Admission,
        name: &str,
    ) -> Result<(), Problem>;
    fn record_path(&self, admission: &Self::Admission) -> PathBuf;
    fn begin(
        &self,
        admission: &Self::Admission,
        task: &Task,
    ) -> Result<(), Problem>;
    fn save(
        &self,
        admission: &Self::Admission,
        task: &Task,
    ) -> Result<(), Problem>;

    // Provided methods
    fn next_generation(
        &self,
        _admission: &Self::Admission,
    ) -> Result<u64, Problem> { ... }
    fn cleanup_retired(
        &self,
        _admission: &Self::Admission,
        _task: &Task,
    ) -> Result<(), Problem> { ... }
    fn record_effect(
        &self,
        admission: &Self::Admission,
        task: &Task,
        index: usize,
        state: EffectState,
    ) -> Result<(), Problem> { ... }
    fn effect(
        &self,
        _admission: &Self::Admission,
        _task: &Task,
        _index: usize,
        _settled: bool,
    ) -> Result<(), Problem> { ... }
}
Expand description

Task admission, publication and effect evidence used by lifecycle operations.

Required Associated Types§

Source

type Admission: Send + Sync

Guard held while reading or mutating a specific task.

Required Methods§

Source

fn verify(&self) -> Result<(), Problem>

Revalidate the workspace binding before relying on its state.

Source

fn validate_destination(&self, path: &Path) -> Result<(), Problem>

Check that the proposed workspace path is available.

Source

fn reserve(&self, path: &Path) -> Result<(), Problem>

Reserve the proposed destination on the filesystem.

Source

fn admit(&self, name: &str) -> Result<Self::Admission, Problem>

Acquire operation admission for the named task.

Source

fn ensure_new( &self, admission: &Self::Admission, name: &str, ) -> Result<(), Problem>

Check under admission that the proposed task can be created.

Source

fn record_path(&self, admission: &Self::Admission) -> PathBuf

Return the authoritative document path for the admitted task.

Source

fn begin(&self, admission: &Self::Admission, task: &Task) -> Result<(), Problem>

Publish initial task state while admission is held.

Source

fn save(&self, admission: &Self::Admission, task: &Task) -> Result<(), Problem>

Publish updated task state while admission is held.

Provided Methods§

Source

fn next_generation(&self, _admission: &Self::Admission) -> Result<u64, Problem>

Allocate a fresh incarnation for this task name.

Source

fn cleanup_retired( &self, _admission: &Self::Admission, _task: &Task, ) -> Result<(), Problem>

Clean up retained state belonging to the retired incarnation.

Source

fn record_effect( &self, admission: &Self::Admission, task: &Task, index: usize, state: EffectState, ) -> Result<(), Problem>

Named entry point; delegates to the legacy hook for existing adapters.

Source

fn effect( &self, _admission: &Self::Admission, _task: &Task, _index: usize, _settled: bool, ) -> Result<(), Problem>

Compatibility hook for existing state adapters.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§