Skip to main content

Control

Struct Control 

Source
pub struct Control<'a>(/* private fields */);
Expand description

Borrow a pinned client for explicit value writes and method calls.

Each call dispatches at most once. A dropped future after dispatch retires the session. If the reply is lost, inspect application state on a new session before deciding what to do.

use opcua_kit::{Client, Control, ControlError, NodeId};
let status = Control::new(client).write_scalar(node, 42_u32).await?;
if status != 0 {
    eprintln!("write returned 0x{status:08X}");
}

Implementations§

Source§

impl Control<'_>

Source

pub async fn acknowledge_condition( &self, condition: &NodeId, event_id: &[u8], comment: Option<ConditionComment<'_>>, ) -> Result<CallOutcome, ConditionError>

Acknowledge the reported branch state by its condition instance and opaque EventId. Supply the ConditionId and EventId from the same notification on this server where AckedState/Id was false. The separate BranchId identifies a retained branch. A server can reject an unknown EventId or an already acknowledged state.

use opcua_kit::{Client, ConditionComment, ConditionError, Control, NodeId};

async fn acknowledge(client: &Client, condition: &NodeId, event_id: &[u8])
    -> Result<u32, ConditionError>
{
    let comment = ConditionComment { locale: "en", text: "Operator reviewed" };
    let result = Control::new(client)
        .acknowledge_condition(condition, event_id, Some(comment))
        .await?;
    Ok(result.status)
}
Source

pub async fn confirm_condition( &self, condition: &NodeId, event_id: &[u8], comment: Option<ConditionComment<'_>>, ) -> Result<CallOutcome, ConditionError>

Confirm the reported branch state by its condition instance and opaque EventId. Use the EventId for the state whose ConfirmedState/Id was false, including when the server issued a new EventId after acknowledgement. Confirm requires server support.

Source§

impl<'a> Control<'a>

Source

pub const fn new(client: &'a Client) -> Self

Use the existing session’s credentials, authority, namespace map and service guard.

Source

pub async fn write_scalar<T: Scalar>( &self, node: &NodeId, value: T, ) -> Result<u32, ControlError>

Write one Rust scalar with its exact OPC UA type and return the full operation status.

Source

pub async fn write_value( &self, node: &NodeId, value: &Variant, ) -> Result<u32, ControlError>

Write the Value attribute only. The Variant retains its exact type and dimensions. The request supplies no data quality or timestamps. Limit: 128 KiB encoded Variant.

Source

pub async fn call_method( &self, object: &NodeId, method: &NodeId, inputs: &[Variant], ) -> Result<CallOutcome, ControlError>

Call one method on the supplied object. The wire inputs and outputs may be heterogeneous. Up to 64 arguments and 128 KiB in aggregate encoded Variant data are accepted per direction. Returns the server’s operation status even for a rejected method or invalid input argument.

use opcua_kit::{Client, Control, NodeId, Scalar};
let args = [42_u64.into_variant()?];
let reply = Control::new(client).call_method(object, method, &args).await?;
if reply.status == 0 && let [result] = reply.outputs.as_slice() {
    let value = u64::from_variant(result)?;
    println!("method returned {value:?}");
}

Auto Trait Implementations§

§

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

§

impl<'a> !UnwindSafe for Control<'a>

§

impl<'a> Forget for Control<'a>

§

impl<'a> Freeze for Control<'a>

§

impl<'a> Move for Control<'a>

§

impl<'a> Send for Control<'a>

§

impl<'a> Sync for Control<'a>

§

impl<'a> Unpin for Control<'a>

§

impl<'a> UnsafeUnpin for Control<'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.