pub struct BwrapCmd<'a> {
chroot_path: Cow<'a, Utf8Path>,
bind_mounts: Vec<(&'a str, &'a str)>,
env_vars: Vec<(&'a str, &'a str)>,
}Expand description
Builder for running commands inside a target directory using bwrap.
Fields§
§chroot_path: Cow<'a, Utf8Path>The target directory to use as root for the container
bind_mounts: Vec<(&'a str, &'a str)>Bind mounts in format (source, target)
env_vars: Vec<(&'a str, &'a str)>Environment variables to set
Implementations§
Source§impl<'a> BwrapCmd<'a>
impl<'a> BwrapCmd<'a>
Sourcepub fn new_with_dir(path: &'a Dir) -> Self
pub fn new_with_dir(path: &'a Dir) -> Self
Create a new BwrapCmd builder with a root directory as a File Descriptor.
Sourcepub fn bind(
self,
source: &'a impl AsRef<Utf8Path>,
target: &'a impl AsRef<Utf8Path>,
) -> Self
pub fn bind( self, source: &'a impl AsRef<Utf8Path>, target: &'a impl AsRef<Utf8Path>, ) -> Self
Add a bind mount from source to target inside the container.
Sourcepub fn setenv(self, key: &'a str, value: &'a str) -> Self
pub fn setenv(self, key: &'a str, value: &'a str) -> Self
Set an environment variable for the command.
Sourcepub fn set_default_path(self) -> Self
pub fn set_default_path(self) -> Self
Set $PATH to a reasonable default for finding system binaries.
The bwrap environment may not have a complete $PATH, causing tools like bootupctl or sfdisk to not be found. This sets a default that covers the standard binary directories.
Sourcefn build_command<S: AsRef<OsStr>>(
&self,
args: impl IntoIterator<Item = S>,
) -> Command
fn build_command<S: AsRef<OsStr>>( &self, args: impl IntoIterator<Item = S>, ) -> Command
Build the bwrap Command with all bind mounts, env vars, and args.
Sourcepub fn run<S: AsRef<OsStr>>(
self,
args: impl IntoIterator<Item = S>,
) -> Result<()>
pub fn run<S: AsRef<OsStr>>( self, args: impl IntoIterator<Item = S>, ) -> Result<()>
Run the specified command inside the container.
Sourcepub fn run_get_string<S: AsRef<OsStr>>(
self,
args: impl IntoIterator<Item = S>,
) -> Result<String>
pub fn run_get_string<S: AsRef<OsStr>>( self, args: impl IntoIterator<Item = S>, ) -> Result<String>
Run the specified command inside the container and capture stdout as a string.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for BwrapCmd<'a>
impl<'a> RefUnwindSafe for BwrapCmd<'a>
impl<'a> Send for BwrapCmd<'a>
impl<'a> Sync for BwrapCmd<'a>
impl<'a> Unpin for BwrapCmd<'a>
impl<'a> UnwindSafe for BwrapCmd<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more