pub trait Host {
// Required methods
fn env(&self, key: &str) -> Option<String>;
fn read_file(&self, path: &Path) -> Result<Vec<u8>>;
fn file_mode(&self, path: &Path) -> Result<Option<u32>>;
fn write_stdout(&mut self, bytes: &[u8]) -> Result<()>;
fn flush_stdout(&mut self) -> Result<()>;
fn write_stderr(&mut self, bytes: &[u8]);
fn is_stdin_interactive(&self) -> bool;
fn is_stdout_terminal(&self) -> bool;
fn read_confirmation(&mut self) -> Result<Option<String>>;
fn new_operation_id(&mut self) -> String;
// Provided method
fn write_new_directory(
&mut self,
_path: &Path,
_files: &[(String, Vec<u8>)],
) -> Result<()> { ... }
}Expand description
The process services one invocation requires.
Required Methods§
Sourcefn env(&self, key: &str) -> Option<String>
fn env(&self, key: &str) -> Option<String>
Reads one environment variable.
A variable that is present but empty is treated as absent, so an empty value never shadows a configuration file.
Sourcefn file_mode(&self, path: &Path) -> Result<Option<u32>>
fn file_mode(&self, path: &Path) -> Result<Option<u32>>
Returns the Unix permission bits of a file, when the platform has them.
§Errors
Returns the underlying metadata failure.
Sourcefn write_stdout(&mut self, bytes: &[u8]) -> Result<()>
fn write_stdout(&mut self, bytes: &[u8]) -> Result<()>
Sourcefn flush_stdout(&mut self) -> Result<()>
fn flush_stdout(&mut self) -> Result<()>
Sourcefn write_stderr(&mut self, bytes: &[u8])
fn write_stderr(&mut self, bytes: &[u8])
Writes a redacted diagnostic to standard error.
A diagnostic write failure never changes the exit category, because the command’s durable effect does not depend on it.
Sourcefn is_stdin_interactive(&self) -> bool
fn is_stdin_interactive(&self) -> bool
Returns whether standard input is an interactive terminal.
Sourcefn is_stdout_terminal(&self) -> bool
fn is_stdout_terminal(&self) -> bool
Returns whether standard output is a terminal that can carry styling.
Sourcefn read_confirmation(&mut self) -> Result<Option<String>>
fn read_confirmation(&mut self) -> Result<Option<String>>
Reads one confirmation response from standard input.
Returns None when input ended without a response. An empty response
is never confirmation.
§Errors
Returns the underlying read failure.
Sourcefn new_operation_id(&mut self) -> String
fn new_operation_id(&mut self) -> String
Returns a fresh operation identifier for an interactive mutation.
The value is printed before the effect is attempted so that an operator can replay the request after an ambiguous outcome.
Provided Methods§
Sourcefn write_new_directory(
&mut self,
_path: &Path,
_files: &[(String, Vec<u8>)],
) -> Result<()>
fn write_new_directory( &mut self, _path: &Path, _files: &[(String, Vec<u8>)], ) -> Result<()>
Atomically writes a new diagnostics-bundle directory.
The target must not already exist. File names are framework-owned, deterministic base names without path traversal.
§Errors
Returns an input/output failure when the target exists, a name is not accepted, or the atomic directory write cannot complete.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".