Skip to main content

RecoveringClient

Struct RecoveringClient 

Source
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>

Source

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().

Source

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.

Source

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.

Source

pub async fn disconnect(self)

Complete any pending attempt and gracefully disconnect its session.

Trait Implementations§

Source§

impl Drop for RecoveringClient<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for RecoveringClient<'a>

§

impl<'a> !RefUnwindSafe for RecoveringClient<'a>

§

impl<'a> Forget for RecoveringClient<'a>

§

impl<'a> Move for RecoveringClient<'a>

§

impl<'a> Send for RecoveringClient<'a>

§

impl<'a> Sync for RecoveringClient<'a>

§

impl<'a> Unpin for RecoveringClient<'a>

§

impl<'a> UnsafeUnpin for RecoveringClient<'a>

§

impl<'a> UnwindSafe for RecoveringClient<'a>

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.