Run

Trait Run 

Source
pub trait Run<B: NixBackend> {
    type Error: 'static + Error + Send + Sync;

    // Required method
    fn run<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        backend: &'life1 B,
        nix_args: &'life2 NixArgs,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Core trait of runix

Implemented for commands that may take a reference of a NixBackend to run a nix command.

§Example

Following example implements Run for a Command on the MyBackend backend.


struct MyBackend;
struct Command;
impl NixBackend for MyBackend {}

#[async_trait::async_trait]
impl Run<MyBackend> for Command {
    type Error = io::Error;

    async fn run(&self, _backend: &MyBackend, _nix_args: &NixArgs) -> Result<(), io::Error> {
        panic!("42")
        // backend.run_in_nix(args)
    }
}

#[tokio::main]
async fn main() {
    Command
        .run(&MyBackend, &NixArgs {
            ..Default::default()
        })
        .await
        .unwrap()
}

Required Associated Types§

Source

type Error: 'static + Error + Send + Sync

Required Methods§

Source

fn run<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, backend: &'life1 B, nix_args: &'life2 NixArgs, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Implementors§