Skip to main content

ClientBuilder

Struct ClientBuilder 

Source
pub struct ClientBuilder { /* private fields */ }
Expand description

Builder for establishing a NETCONF client connection.

§Examples

use rustnetconf::Client;

let client = Client::connect("10.0.0.1:830")
    .username("admin")
    .password("secret")
    .connect()
    .await?;

Implementations§

Source§

impl ClientBuilder

Source

pub fn username(self, username: &str) -> Self

Set the SSH username.

Source

pub fn password(self, password: &str) -> Self

Set the SSH password for authentication.

Source

pub fn key_file(self, path: &str) -> Self

Set the path to an SSH private key file.

Source

pub fn key_passphrase(self, passphrase: &str) -> Self

Set the passphrase for the SSH private key.

Source

pub fn ssh_agent(self) -> Self

Use the SSH agent for authentication.

Source

pub fn vendor_profile(self, profile: Box<dyn VendorProfile>) -> Self

Set an explicit vendor profile, overriding auto-detection.

Use this when auto-detection doesn’t work for your device, or when using a custom vendor implementation.

Source

pub fn gather_facts(self, gather: bool) -> Self

Control whether device facts are gathered after connecting.

When true (the default), the client sends a vendor-specific RPC (e.g., <get-system-information/> on Junos) to populate Client::facts() with the device’s hostname, model, version, and serial number.

Set to false to skip facts gathering — useful for clustered devices where the facts RPC may fail if a peer node is unreachable. Facts can be gathered later via Client::gather_facts().

Source

pub fn keepalive_interval(self, interval: Duration) -> Self

Set a keepalive interval for automatic session health checks.

When set, the client tracks the time since the last successful RPC. Before each RPC, if more than interval has elapsed, a lightweight probe is sent first. If the probe fails, the session is marked dead and the caller can reconnect().

Default: no keepalive (disabled).

Source

pub fn host_key_verification(self, policy: HostKeyVerification) -> Self

Set the SSH host key verification policy.

Controls how the client validates the device’s SSH host key during connection to protect against man-in-the-middle attacks.

Default: HostKeyVerification::AcceptAll (a warning is logged).

§Examples
use rustnetconf::Client;
use rustnetconf::transport::ssh::HostKeyVerification;

let client = Client::connect("10.0.0.1:830")
    .username("admin")
    .password("secret")
    .host_key_verification(HostKeyVerification::Fingerprint(
        "SHA256:abc123...".to_string(),
    ))
    .connect()
    .await?;
Source

pub async fn connect(self) -> Result<Client, NetconfError>

Establish the SSH connection and perform the NETCONF hello exchange.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more