pub struct AnvilConfigBuilder { /* private fields */ }Expand description
Builder for AnvilConfig.
Obtained via AnvilConfig::builder.
Implementations§
Source§impl AnvilConfigBuilder
impl AnvilConfigBuilder
Sourcepub fn username(self, username: impl Into<String>) -> Self
pub fn username(self, username: impl Into<String>) -> Self
Override the remote username (default: "git", FR-13).
Sourcepub fn add_identity_file(self, path: impl Into<PathBuf>) -> Self
pub fn add_identity_file(self, path: impl Into<PathBuf>) -> Self
Append path to the ordered identity-file list (FR-9).
Use this to add CLI-supplied keys; ssh_config-supplied keys flow
in through Self::apply_ssh_config. Both can coexist; auth
tries them in the order they were added.
Sourcepub fn identity_files(self, paths: Vec<PathBuf>) -> Self
pub fn identity_files(self, paths: Vec<PathBuf>) -> Self
Replace the entire identity-file list with paths. Existing
entries are discarded.
Sourcepub fn identity_file(self, path: impl Into<PathBuf>) -> Self
👎Deprecated since 0.3.0: use add_identity_file or identity_files for the multi-key API
pub fn identity_file(self, path: impl Into<PathBuf>) -> Self
use add_identity_file or identity_files for the multi-key API
Set a single identity-file path, replacing any existing entries.
0.2.x compatibility shim. New code should use
Self::add_identity_file (additive) or Self::identity_files
(replace-all) for clarity.
Sourcepub fn cert_file(self, path: impl Into<PathBuf>) -> Self
pub fn cert_file(self, path: impl Into<PathBuf>) -> Self
Set an OpenSSH certificate path (FR-12).
Sourcepub fn strict_host_key_checking(self, policy: StrictHostKeyChecking) -> Self
pub fn strict_host_key_checking(self, policy: StrictHostKeyChecking) -> Self
Set the host-key verification policy (FR-8).
Sourcepub fn skip_host_check(self, skip: bool) -> Self
👎Deprecated since 0.3.0: use strict_host_key_checking(StrictHostKeyChecking::No) for clarity
pub fn skip_host_check(self, skip: bool) -> Self
use strict_host_key_checking(StrictHostKeyChecking::No) for clarity
Disable host-key verification. Use only for emergencies (FR-8).
true maps to StrictHostKeyChecking::No; false to
StrictHostKeyChecking::Yes. Lossless from the 0.2.x boolean
shape (which only encoded those two states).
Sourcepub fn inactivity_timeout(self, timeout: Duration) -> Self
pub fn inactivity_timeout(self, timeout: Duration) -> Self
Override the session inactivity timeout (FR-5).
Sourcepub fn custom_known_hosts(self, path: impl Into<PathBuf>) -> Self
pub fn custom_known_hosts(self, path: impl Into<PathBuf>) -> Self
Path to a custom known_hosts-style file for self-hosted instances
(FR-7).
Sourcepub fn fallback(self, fallback: Option<(String, u16)>) -> Self
pub fn fallback(self, fallback: Option<(String, u16)>) -> Self
Override the fallback host/port. Pass None to disable fallback.
Sourcepub fn kex_algorithms(self, list: Option<Vec<String>>) -> Self
pub fn kex_algorithms(self, list: Option<Vec<String>>) -> Self
Override the key-exchange algorithm preference (PRD §5.8.6 FR-76).
Pass None to keep the curated default
(crate::algorithms::anvil_default_kex). The list is
expected to have already passed through
crate::algorithms::apply_overrides so any
+/-/^ prefix is resolved and the FR-78 denylist applied.
Sourcepub fn ciphers(self, list: Option<Vec<String>>) -> Self
pub fn ciphers(self, list: Option<Vec<String>>) -> Self
Override the cipher preference (PRD §5.8.6 FR-76).
Sourcepub fn macs(self, list: Option<Vec<String>>) -> Self
pub fn macs(self, list: Option<Vec<String>>) -> Self
Override the MAC preference (PRD §5.8.6 FR-76).
Sourcepub fn host_key_algorithms(self, list: Option<Vec<String>>) -> Self
pub fn host_key_algorithms(self, list: Option<Vec<String>>) -> Self
Override the host-key algorithm preference (PRD §5.8.6 FR-76).
Sourcepub fn connect_timeout(self, timeout: Option<Duration>) -> Self
pub fn connect_timeout(self, timeout: Option<Duration>) -> Self
Override the per-attempt TCP connect timeout (PRD §5.8.7
FR-80). None disables the timeout. CLI overrides this
AFTER apply_ssh_config so flags beat config (matches
OpenSSH precedence).
Sourcepub fn connection_attempts(self, attempts: Option<u32>) -> Self
pub fn connection_attempts(self, attempts: Option<u32>) -> Self
Override the total connection-attempt count (PRD §5.8.7
FR-80). None selects the curated default (3).
Sourcepub fn max_retry_window(self, window: Option<Duration>) -> Self
pub fn max_retry_window(self, window: Option<Duration>) -> Self
Override the wall-clock cap on total retry time (PRD
§5.8.7 FR-81). None selects the curated default (30 s).
Not part of OpenSSH’s ssh_config(5) grammar — CLI-only.
Sourcepub fn apply_ssh_config(self, resolved: &ResolvedSshConfig) -> Self
pub fn apply_ssh_config(self, resolved: &ResolvedSshConfig) -> Self
Layer values from a ResolvedSshConfig into this builder.
Provides ssh_config-derived defaults that subsequent builder calls can still override (call this before CLI-derived overrides if you want CLI to win). The following mappings are applied:
ssh_config directive | Builder field |
|---|---|
HostName | host (overridden) |
Port | port (overridden) |
User | username (overridden) |
IdentityFile (multi) | identity_files (extended) |
StrictHostKeyChecking | strict_host_key_checking (overridden) |
UserKnownHostsFile (first) | custom_known_hosts (filled if None) |
Algorithm directives (HostKeyAlgorithms, KexAlgorithms,
Ciphers, MACs) are honored as of M17 (PRD §5.8.6 FR-76):
each parsed AlgList is fed through
crate::algorithms::apply_overrides against the matching
curated default, so an ssh_config value of +algo,algo
appends to Anvil’s defaults rather than replacing them.
ConnectTimeout / ConnectionAttempts remain deferred to
M18.
§Errors
This method is infallible by signature, but a malformed
algorithm list (denylisted entry referenced by an override)
is logged at warn level and silently dropped — the
connection then falls back to the curated default. Callers
who want strict validation should run the same value
through crate::algorithms::apply_overrides explicitly
before calling here.
Sourcepub fn build(self) -> AnvilConfig
pub fn build(self) -> AnvilConfig
Finalise and return the AnvilConfig.