Trait Progress

Source
pub trait Progress: Send {
    type T: Send;
    type Error: From<Error> + Send + Sync;

    // Required methods
    fn next(
        &mut self,
    ) -> impl Future<Output = Result<Option<Stderr>, Self::Error>> + Send;
    fn result(self) -> impl Future<Output = Result<Self::T, Self::Error>> + Send;
}
Expand description

An in-progress operation, which may produces a series of Stderrs before returning.

All functions on the Store trait return these wrappers. If you just want the final result, not play-by-play updates on eg. log output or paths built:

use nix_daemon::{Store, Progress, nix::DaemonStore};
let is_valid_path = store.is_valid_path("/nix/store/...").result().await?;

Otherwise, if you are interested in (some of) the progress updates:

use nix_daemon::{Store, Progress, nix::DaemonStore};
let mut prog = store.is_valid_path("/nix/store/...");
while let Some(stderr) = prog.next().await? {
    match stderr {
        _ => todo!(),
    }
}
let is_valid_path = prog.result().await?;

Required Associated Types§

Required Methods§

Source

fn next( &mut self, ) -> impl Future<Output = Result<Option<Stderr>, Self::Error>> + Send

Returns the next Stderr message, or None after all have been consumed. This must behave like a fused iterator - once None is returned, all further calls must immediately return None, without corrupting the underlying datastream, etc.

Source

fn result(self) -> impl Future<Output = Result<Self::T, Self::Error>> + Send

Discards any further messages from Self::next() and proceeds.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§