pub struct CmdOptions { /* private fields */ }Expand description
CmdOptions are used to describe command’s additional settings.
It allows to configure command’s input/outputs, working_directory and environment variables.
Command’s input allows to send messages from parent process, and receive them in spawned (child) process. Whereas the message output of the command is used for communication in the opposite direction. Communication with a process can be done using standard I/O or named pipes.
It is also possible to set logging in order to allow child process to produce logs which, unlike messages, are stored permanently and therefore can be read multiple times by parent process.
Implementations§
Source§impl CmdOptions
impl CmdOptions
Sourcepub fn with_standard_io_messaging() -> CmdOptions
pub fn with_standard_io_messaging() -> CmdOptions
Create options with configured messaging input/output via standard I/O.
Sourcepub fn with_named_pipe_messaging() -> CmdOptions
pub fn with_named_pipe_messaging() -> CmdOptions
Create options with configured messaging input/output via named pipes.
Sourcepub fn with_message_input(message_input: MessagingType) -> Self
pub fn with_message_input(message_input: MessagingType) -> Self
Create options with configured messaging input type.
Sourcepub fn with_message_output(message_output: MessagingType) -> Self
pub fn with_message_output(message_output: MessagingType) -> Self
Create options with configured messaging output type.
Sourcepub fn with_logging(logging_type: LoggingType) -> Self
pub fn with_logging(logging_type: LoggingType) -> Self
Create options with configured logging type.
Sourcepub fn set_current_dir(&mut self, dir: PathBuf)
pub fn set_current_dir(&mut self, dir: PathBuf)
Set process’s working directory.
Sourcepub fn clear_inherited_envs(&mut self, value: bool)
pub fn clear_inherited_envs(&mut self, value: bool)
By default, child process will inherit all environment variables from the parent.
To prevent this behavior set this value to true.
Sourcepub fn set_envs<K, V, I>(&mut self, envs: I)
pub fn set_envs<K, V, I>(&mut self, envs: I)
Set environment variables for a process.
§Examples
let mut envs = HashMap::new();
envs.insert("TEST_ENV_VAR_1", "value1");
envs.insert("TEST_ENV_VAR_2", "value2");
let mut options = CmdOptions::default();
options.set_envs(envs);Sourcepub fn remove_env<S>(&mut self, name: S)
pub fn remove_env<S>(&mut self, name: S)
Remove single environment variable (manually set earlier and also inherited from the parent process).
Sourcepub fn set_message_input(&mut self, messaging_type: MessagingType)
pub fn set_message_input(&mut self, messaging_type: MessagingType)
Set message input type.
Sourcepub fn set_message_output(
&mut self,
messaging_type: MessagingType,
) -> Result<(), CmdOptionsError>
pub fn set_message_output( &mut self, messaging_type: MessagingType, ) -> Result<(), CmdOptionsError>
Set message output type.
This method will return CmdOptionsError::StdoutConfigurationConflict
when trying to set MessagingType::StandardIo and logging to stdout was previously configured.
Sourcepub fn set_logging_type(
&mut self,
logging_type: LoggingType,
) -> Result<(), CmdOptionsError>
pub fn set_logging_type( &mut self, logging_type: LoggingType, ) -> Result<(), CmdOptionsError>
Set logging type.
This method will return CmdOptionsError::StdoutConfigurationConflict
when trying to set logging to stdout and message output was previously configured as MessagingType::StandardIo.
Sourcepub fn set_message_output_buffer_capacity(&mut self, capacity: BufferCapacity)
pub fn set_message_output_buffer_capacity(&mut self, capacity: BufferCapacity)
Set message output buffer capacity for receiving end (parent process).
When parent process is not reading messages produced by a child process,
then the messages are buffered up to the given capacity value.
If the buffer limit is reached and a child process sends a new message, the “oldest” buffered message will be removed.
Trait Implementations§
Source§impl Clone for CmdOptions
impl Clone for CmdOptions
Source§fn clone(&self) -> CmdOptions
fn clone(&self) -> CmdOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more