Skip to main content

WriteService

Trait WriteService 

Source
pub trait WriteService:
    Send
    + Sync
    + 'static {
    type Operation: Serialize + DeserializeOwned + Clone + Send + Sync + 'static;
    type Prepared: Send + Sync + 'static;

    // Required methods
    fn validate(&self, operations: &[Self::Operation]) -> Result<(), String>;
    fn preflight(
        &self,
        operations: &[Self::Operation],
    ) -> Result<Self::Prepared, String>;
    fn describe(
        &self,
        operations: &[Self::Operation],
        prepared: &Self::Prepared,
    ) -> String;
    fn write(
        &self,
        index: usize,
        operation: &Self::Operation,
        prepared: &Self::Prepared,
    ) -> Result<Value, String>;

    // Provided methods
    fn requires_app_approval(&self, _operations: &[Self::Operation]) -> bool { ... }
    fn preflight_monitored(
        &self,
        operations: &[Self::Operation],
        monitor: &dyn CallMonitor,
    ) -> Result<Self::Prepared, String> { ... }
    fn write_monitored(
        &self,
        index: usize,
        operation: &Self::Operation,
        prepared: &Self::Prepared,
        _monitor: &dyn CallMonitor,
    ) -> Result<Value, String> { ... }
}
Expand description

A board’s write actions.

Required Associated Types§

Source

type Operation: Serialize + DeserializeOwned + Clone + Send + Sync + 'static

A strict, action-tagged enum; the preview prints it as JSON.

Source

type Prepared: Send + Sync + 'static

What the preflight learned, for the preview and for the writes.

Required Methods§

Source

fn validate(&self, operations: &[Self::Operation]) -> Result<(), String>

The checks that need no service call, such as targets in scope.

Source

fn preflight( &self, operations: &[Self::Operation], ) -> Result<Self::Prepared, String>

Reads each target before the approval.

Source

fn describe( &self, operations: &[Self::Operation], prepared: &Self::Prepared, ) -> String

What the JSON preview cannot show, such as resolved titles.

Source

fn write( &self, index: usize, operation: &Self::Operation, prepared: &Self::Prepared, ) -> Result<Value, String>

Runs operation index exactly as the preflight prepared it.

Provided Methods§

Source

fn requires_app_approval(&self, _operations: &[Self::Operation]) -> bool

Config edits and other sensitive operations cannot use client-side or unattended approval. Existing service writes retain normal approval.

Source

fn preflight_monitored( &self, operations: &[Self::Operation], monitor: &dyn CallMonitor, ) -> Result<Self::Prepared, String>

Cancellable preflight; existing boards keep their current behavior.

Source

fn write_monitored( &self, index: usize, operation: &Self::Operation, prepared: &Self::Prepared, _monitor: &dyn CallMonitor, ) -> Result<Value, String>

Cancellable active operation; called only after the invocation’s approval.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§