Struct elevated_command::Command
source · pub struct Command { /* private fields */ }Expand description
Wrap of std::process::command and escalate privileges while executing
Implementations§
source§impl Command
impl Command
Command initialization shares the same logic across all the platforms
sourcepub fn new(cmd: StdCommand) -> Self
pub fn new(cmd: StdCommand) -> Self
Constructs a new Command from a std::process::Command
instance, it would read the following configuration from
the instance while executing:
- The instance’s path to the program
- The instance’s arguments
- The instance’s environment variables
- The instance’s working directory
Examples
use elevated_command::Command;
use std::process::Command as StdCommand;
fn main() {
let mut cmd = StdCommand::new("path to the application");
cmd.arg("some arg");
cmd.env("some key", "some value");
let elevated_cmd = Command::new(cmd);
}sourcepub fn into_inner(self) -> StdCommand
pub fn into_inner(self) -> StdCommand
Consumes the Take, returning the wrapped std::process::Command
Examples
use elevated_command::Command;
use std::process::Command as StdCommand;
fn main() {
let mut cmd = StdCommand::new("path to the application");
let elevated_cmd = Command::new(cmd);
let cmd = elevated_cmd.into_inner();
}sourcepub fn get_ref(&self) -> &StdCommand
pub fn get_ref(&self) -> &StdCommand
Gets a mutable reference to the underlying std::process::Command
Examples
use elevated_command::Command;
use std::process::Command as StdCommand;
fn main() {
let mut cmd = StdCommand::new("path to the application");
let elevated_cmd = Command::new(cmd);
let cmd = elevated_cmd.get_ref();
}sourcepub fn get_mut(&mut self) -> &mut StdCommand
pub fn get_mut(&mut self) -> &mut StdCommand
Gets a reference to the underlying std::process::Command
Examples
use elevated_command::Command;
use std::process::Command as StdCommand;
fn main() {
let mut cmd = StdCommand::new("path to the application");
let elevated_cmd = Command::new(cmd);
let cmd = elevated_cmd.get_mut();
}sourcepub fn icon(&mut self, icon: Vec<u8>) -> &mut Self
pub fn icon(&mut self, icon: Vec<u8>) -> &mut Self
Set the icon for the pop-up graphical OS dialog
This method is only applicable on MacOS
Examples
use elevated_command::Command;
use std::process::Command as StdCommand;
fn main() {
let mut cmd = StdCommand::new("path to the application");
let elevated_cmd = Command::new(cmd);
elevated_cmd.icon(include_bytes!("path to the icon").to_vec());
}sourcepub fn name(&mut self, name: String) -> &mut Self
pub fn name(&mut self, name: String) -> &mut Self
Set the name for the pop-up graphical OS dialog
This method is only applicable on MacOS
Examples
use elevated_command::Command;
use std::process::Command as StdCommand;
fn main() {
let mut cmd = StdCommand::new("path to the application");
let elevated_cmd = Command::new(cmd);
elevated_cmd.name("some name".to_string());
}Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl !UnwindSafe for Command
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
Mutably borrows from an owned value. Read more