stak_process_context/process_context/
memory.rs

1use crate::ProcessContext;
2
3/// A in-memory process context.
4#[derive(Debug)]
5pub struct MemoryProcessContext<'a> {
6    arguments: &'a [&'a str],
7    environment_variables: &'a [(&'a str, &'a str)],
8}
9
10impl<'a> MemoryProcessContext<'a> {
11    /// Creates a process context.
12    pub const fn new(
13        arguments: &'a [&'a str],
14        environment_variables: &'a [(&'a str, &'a str)],
15    ) -> Self {
16        Self {
17            arguments,
18            environment_variables,
19        }
20    }
21}
22
23impl ProcessContext for MemoryProcessContext<'_> {
24    fn command_line_rev(&self) -> impl IntoIterator<Item = &str> {
25        self.arguments.iter().rev().copied()
26    }
27
28    fn environment_variables(&self) -> impl IntoIterator<Item = (&str, &str)> {
29        self.environment_variables.iter().copied()
30    }
31}