Skip to main content

WriteGuard

Trait WriteGuard 

Source
pub trait WriteGuard: Send + Sync {
    // Required method
    fn before_write<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Renews the engine’s hold on the creates a guarded call writes for, before each request.

Required Methods§

Source

fn before_write<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), SourceError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Renew, and answer whether the next write request may be sent: an error is the reason it may not — another attempt holds the create — and every later ask answers it again, so a source sends nothing more, not even a write taking back what it made.

§Errors

The refusal the source is to fail its call with, sending nothing more.

Implementations§

Source§

impl dyn WriteGuard

Source

pub async fn scope<F: Future>(guard: Arc<dyn WriteGuard>, call: F) -> F::Output

Run call with guard answering every [<dyn WriteGuard>::check] made inside it.

Source

pub async fn check() -> Result<(), SourceError>

Ask the guard of the call in progress, if any, whether a write request may be sent now — a source calls this immediately before sending each write request but its create.

§Errors

The guard’s refusal; with no guard installed, never.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§