pub struct PoolGuard<'a> { /* private fields */ }Expand description
A checked-out connection from the pool.
Dereferences to Client for direct use. Automatically returns the
connection to the pool when dropped (if the session is still alive).
Broken sessions are discarded.
Implementations§
Methods from Deref<Target = Client>§
Sourcepub async fn rpc(&mut self, rpc_content: &str) -> Result<String, NetconfError>
pub async fn rpc(&mut self, rpc_content: &str) -> Result<String, NetconfError>
Send an arbitrary RPC and return the raw XML response content.
The rpc_content is wrapped in <rpc> tags with a message-id,
sent to the device, and the inner content of <rpc-reply> is returned.
Use this for vendor-specific RPCs not covered by the standard NETCONF operations (get-config, edit-config, etc.).
Sourcepub fn supports(&self, capability_uri: &str) -> bool
pub fn supports(&self, capability_uri: &str) -> bool
Check if the device supports a specific capability URI.
Sourcepub fn vendor_name(&self) -> &str
pub fn vendor_name(&self) -> &str
Get the detected or configured vendor name (e.g., “junos”, “generic”).
Sourcepub fn capabilities(&self) -> Option<&Capabilities>
pub fn capabilities(&self) -> Option<&Capabilities>
Get the device’s capabilities.
Sourcepub fn facts(&self) -> &Facts
pub fn facts(&self) -> &Facts
Get the device facts (hostname, model, version, serial number).
Returns an empty Facts if gather_facts(false) was used during
connection and gather_facts() hasn’t been
called yet.
Sourcepub async fn gather_facts(&mut self) -> Result<(), NetconfError>
pub async fn gather_facts(&mut self) -> Result<(), NetconfError>
Gather device facts by sending the vendor-specific facts RPC.
Use this to manually populate facts after connecting with
gather_facts(false). Can also be called to refresh facts.
Sourcepub fn session_alive(&self) -> bool
pub fn session_alive(&self) -> bool
Check if the session is alive (established and not closed).
This is a fast in-memory check — it does not send any RPC to the device. Use this to detect sessions that have been explicitly closed or marked dead by a failed keepalive probe.
For a thorough check that verifies the transport is responsive,
see probe_session().
Sourcepub async fn probe_session(&mut self) -> bool
pub async fn probe_session(&mut self) -> bool
Probe the session by sending a lightweight RPC to verify the transport is responsive.
Returns true if the device responded, false if the probe failed
(in which case the session is marked dead).
Sourcepub async fn reconnect(&mut self) -> Result<(), NetconfError>
pub async fn reconnect(&mut self) -> Result<(), NetconfError>
Re-establish the NETCONF session using the original connection parameters.
Closes the current session (if still open) and creates a fresh SSH
connection, performs the hello exchange, and optionally gathers facts
(matching the original gather_facts setting).
This is idempotent — safe to call even if the session is already dead.
Sourcepub async fn get_config(
&mut self,
source: Datastore,
) -> Result<String, NetconfError>
pub async fn get_config( &mut self, source: Datastore, ) -> Result<String, NetconfError>
Fetch configuration from a datastore.
Sourcepub async fn get_config_filtered(
&mut self,
source: Datastore,
filter: &str,
) -> Result<String, NetconfError>
pub async fn get_config_filtered( &mut self, source: Datastore, filter: &str, ) -> Result<String, NetconfError>
Fetch configuration with a subtree filter.
Sourcepub async fn get(
&mut self,
filter: Option<&str>,
) -> Result<String, NetconfError>
pub async fn get( &mut self, filter: Option<&str>, ) -> Result<String, NetconfError>
Fetch operational and configuration data.
Sourcepub fn edit_config(&mut self, target: Datastore) -> EditConfigBuilder<'_>
pub fn edit_config(&mut self, target: Datastore) -> EditConfigBuilder<'_>
Start building an edit-config operation.
Sourcepub async fn unlock(&mut self, target: Datastore) -> Result<(), NetconfError>
pub async fn unlock(&mut self, target: Datastore) -> Result<(), NetconfError>
Unlock a datastore.
Sourcepub async fn discard_changes(&mut self) -> Result<(), NetconfError>
pub async fn discard_changes(&mut self) -> Result<(), NetconfError>
Discard uncommitted candidate changes.
Sourcepub async fn commit(&mut self) -> Result<(), NetconfError>
pub async fn commit(&mut self) -> Result<(), NetconfError>
Commit the candidate configuration.
Sourcepub async fn validate(&mut self, source: Datastore) -> Result<(), NetconfError>
pub async fn validate(&mut self, source: Datastore) -> Result<(), NetconfError>
Validate a datastore.
Sourcepub async fn close_session(&mut self) -> Result<(), NetconfError>
pub async fn close_session(&mut self) -> Result<(), NetconfError>
Close the NETCONF session gracefully.
Sourcepub async fn kill_session(
&mut self,
session_id: u32,
) -> Result<(), NetconfError>
pub async fn kill_session( &mut self, session_id: u32, ) -> Result<(), NetconfError>
Kill another NETCONF session by ID.
Sourcepub async fn confirmed_commit(
&mut self,
confirm_timeout: u32,
) -> Result<(), NetconfError>
pub async fn confirmed_commit( &mut self, confirm_timeout: u32, ) -> Result<(), NetconfError>
Confirmed commit with automatic rollback timeout.
The device applies the candidate configuration but automatically
rolls back if confirming_commit is not
called within confirm_timeout seconds.
Requires the :confirmed-commit capability.
Sourcepub async fn confirming_commit(&mut self) -> Result<(), NetconfError>
pub async fn confirming_commit(&mut self) -> Result<(), NetconfError>
Confirm a previous confirmed-commit, making it permanent.
Sourcepub async fn lock_or_kill_stale(
&mut self,
target: Datastore,
) -> Result<Option<u32>, NetconfError>
pub async fn lock_or_kill_stale( &mut self, target: Datastore, ) -> Result<Option<u32>, NetconfError>
Lock a datastore, killing a stale session if the lock is held.
If the lock is denied because another (possibly crashed) session holds it, extracts the blocking session-id from the error and kills that session, then retries the lock.
Returns Ok(Some(killed_session_id)) if a stale session was killed,
or Ok(None) if the lock was acquired without contention.
Sourcepub async fn rpc_with_warnings(
&mut self,
rpc_content: &str,
) -> Result<(String, Vec<RpcErrorInfo>), NetconfError>
pub async fn rpc_with_warnings( &mut self, rpc_content: &str, ) -> Result<(String, Vec<RpcErrorInfo>), NetconfError>
Send an arbitrary RPC, returning both the response and any warnings.
Like rpc(), but returns warnings alongside the data.
Sourcepub async fn open_configuration(
&mut self,
mode: OpenConfigurationMode,
) -> Result<(), NetconfError>
pub async fn open_configuration( &mut self, mode: OpenConfigurationMode, ) -> Result<(), NetconfError>
Open a private or exclusive configuration database (Junos).
Required on chassis-clustered Junos devices before loading configuration. On standalone devices this is optional but harmless.
Sourcepub async fn close_configuration(&mut self) -> Result<(), NetconfError>
pub async fn close_configuration(&mut self) -> Result<(), NetconfError>
Close a previously opened configuration database (Junos).
Sourcepub async fn commit_configuration(&mut self) -> Result<(), NetconfError>
pub async fn commit_configuration(&mut self) -> Result<(), NetconfError>
Commit using the Junos-native <commit-configuration/> RPC.
Use this instead of commit() on Junos devices,
especially when a private/exclusive configuration database is open.
Sourcepub async fn rollback_configuration(
&mut self,
rollback: u32,
) -> Result<(), NetconfError>
pub async fn rollback_configuration( &mut self, rollback: u32, ) -> Result<(), NetconfError>
Rollback the candidate configuration to a previous commit (Junos).
rollback is the rollback index (0 = most recent commit, up to 49).
Sourcepub async fn get_configuration_compare(
&mut self,
rollback: u32,
) -> Result<String, NetconfError>
pub async fn get_configuration_compare( &mut self, rollback: u32, ) -> Result<String, NetconfError>
Get the diff between candidate and a previous commit (Junos).
Returns the text-format diff. rollback is the rollback index
(0 = most recent commit).
Sourcepub async fn load_configuration(
&mut self,
action: LoadAction,
format: LoadFormat,
config: &str,
) -> Result<String, NetconfError>
pub async fn load_configuration( &mut self, action: LoadAction, format: LoadFormat, config: &str, ) -> Result<String, NetconfError>
Load configuration using the Junos <load-configuration> RPC.
On chassis-clustered devices, call
open_configuration() first.
Sourcepub fn requires_open_configuration(&self) -> bool
pub fn requires_open_configuration(&self) -> bool
Whether this device requires <open-configuration> before loading config.
Returns true for Junos chassis-clustered devices.
Sourcepub async fn create_subscription(
&mut self,
stream: Option<&str>,
filter: Option<&str>,
start_time: Option<&str>,
stop_time: Option<&str>,
) -> Result<(), NetconfError>
pub async fn create_subscription( &mut self, stream: Option<&str>, filter: Option<&str>, start_time: Option<&str>, stop_time: Option<&str>, ) -> Result<(), NetconfError>
Create a notification subscription (RFC 5277).
Requires the :notification capability. After subscription, the device
sends <notification> messages asynchronously. Retrieve them with
drain_notifications() or
recv_notification().
Sourcepub fn drain_notifications(&mut self) -> Vec<Notification>
pub fn drain_notifications(&mut self) -> Vec<Notification>
Drain all buffered notifications, returning them and clearing the buffer.
Notifications are buffered when they arrive during RPC exchanges.
Sourcepub async fn recv_notification(
&mut self,
) -> Result<Option<Notification>, NetconfError>
pub async fn recv_notification( &mut self, ) -> Result<Option<Notification>, NetconfError>
Wait for the next notification from the device.
Returns Ok(None) if the connection is closed.
Sourcepub fn has_notifications(&self) -> bool
pub fn has_notifications(&self) -> bool
Check if any notifications are buffered without blocking.
Sourcepub fn has_subscription(&self) -> bool
pub fn has_subscription(&self) -> bool
Whether this session has an active notification subscription.