Skip to main content

Host

Trait Host 

Source
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§

Source

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.

Source

fn read_file(&self, path: &Path) -> Result<Vec<u8>>

Reads one file.

§Errors

Returns the underlying input/output failure.

Source

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.

Source

fn write_stdout(&mut self, bytes: &[u8]) -> Result<()>

Writes to standard output.

§Errors

Returns the underlying write failure, including a closed pipe.

Source

fn flush_stdout(&mut self) -> Result<()>

Flushes standard output.

§Errors

Returns the underlying flush failure.

Source

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.

Source

fn is_stdin_interactive(&self) -> bool

Returns whether standard input is an interactive terminal.

Source

fn is_stdout_terminal(&self) -> bool

Returns whether standard output is a terminal that can carry styling.

Source

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.

Source

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§

Source

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".

Implementors§