pub struct RecoveringClient<'a> { /* private fields */ }Expand description
Reuses a pinned client until a channel change or failed/cancelled read retires its session.
Each call to Self::session starts at most one connection attempt with the original endpoint,
credentials, identity, policy and timeout. Schedule further attempts and backoff in the host.
A lost read remains visible to the caller. A fresh generation does not replay observations.
use opcua_kit::{NodeId, client::{RecoveringClient, SessionState}};
async fn poll(owner: &mut RecoveringClient<'_>, node: &NodeId) -> Result<(), Box<dyn std::error::Error>> {
let session = owner.session().await?;
if session.state == SessionState::Reconnected {
eprintln!("coverage gap before generation {}", session.generation);
}
let sample = session.client.read_scalar::<u64>(node).await?;
println!("status={:#010x} register={:?}", sample.status, sample.value);
Ok(())
}Implementations§
Source§impl<'a> RecoveringClient<'a>
impl<'a> RecoveringClient<'a>
Sourcepub fn new(config: ConnectionConfig<'a>, options: ConnectionOptions<'a>) -> Self
pub fn new(config: ConnectionConfig<'a>, options: ConnectionOptions<'a>) -> Self
Bind the peer and credentials used for every generation. Network I/O begins at session().
Sourcepub fn new_with_rollover(
config: ConnectionConfig<'a>,
options: ConnectionOptions<'a>,
rollover: CertificateRollover<'a>,
) -> Self
pub fn new_with_rollover( config: ConnectionConfig<'a>, options: ConnectionOptions<'a>, rollover: CertificateRollover<'a>, ) -> Self
Apply the same bounded two-leaf trust policy to each fresh handshake.
Sourcepub async fn session(&mut self) -> Result<RecoveredSession<'_>, RecoveryError>
pub async fn session(&mut self) -> Result<RecoveredSession<'_>, RecoveryError>
Acquire an authenticated session. The blocking handshake runs on a worker. Dropping this future leaves any pending attempt with the owner so its next call joins the same attempt.
Check the generation before using results or recreating monitored items. The session lease reflects known channel and read failures; the socket can still fail during any operation.
Sourcepub async fn disconnect(self)
pub async fn disconnect(self)
Complete any pending attempt and gracefully disconnect its session.