Trait nix_daemon::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/...").await?.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/...").await?;
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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'s, C, T: Send, F, FF> Progress for DaemonProgress<'s, C, T, F, FF>
where C: AsyncReadExt + AsyncWriteExt + Unpin + Send, F: FnOnce(&'s mut DaemonStore<C>) -> FF + Send, FF: Future<Output = Result<T>> + Send,

§

type T = T

§

type Error = Error