Skip to main content

Backend

Trait Backend 

Source
pub trait Backend {
    // Required methods
    fn validate(
        &self,
        config: &HostsConfig,
    ) -> Result<Vec<ValidationResult>, HostsError>;
    fn update(&self, config: &HostsConfig) -> Result<String, HostsError>;
    fn remove(&self, hostnames: &[String]) -> Result<String, HostsError>;
    fn generate_manual_instructions(&self, config: &HostsConfig) -> String;
}
Expand description

Ported from the Backend interface in interface.go.

Required Methods§

Source

fn validate( &self, config: &HostsConfig, ) -> Result<Vec<ValidationResult>, HostsError>

Checks if hostnames in /etc/hosts match the expected configuration. Returns validation results for any hostnames that are missing or incorrect; an empty result means all are valid.

Source

fn update(&self, config: &HostsConfig) -> Result<String, HostsError>

Computes the new /etc/hosts content with hostnames added or updated. Does not write the file.

Source

fn remove(&self, hostnames: &[String]) -> Result<String, HostsError>

Computes the new /etc/hosts content with hostnames removed. Does not write the file.

Source

fn generate_manual_instructions(&self, config: &HostsConfig) -> String

Generates instructions for manually updating /etc/hosts.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§