pub trait SubscriptionService: Service {
// Required methods
fn create_subscription<CB>(
&self,
publishing_interval: f64,
lifetime_count: u32,
max_keep_alive_count: u32,
max_notifications_per_publish: u32,
priority: u8,
publishing_enabled: bool,
callback: CB,
) -> Result<u32, StatusCode>
where CB: OnSubscriptionNotification + Send + Sync + 'static;
fn modify_subscription(
&self,
subscription_id: u32,
publishing_interval: f64,
lifetime_count: u32,
max_keep_alive_count: u32,
max_notifications_per_publish: u32,
priority: u8,
) -> Result<(), StatusCode>;
fn set_publishing_mode(
&self,
subscription_ids: &[u32],
publishing_enabled: bool,
) -> Result<Vec<StatusCode>, StatusCode>;
fn transfer_subscriptions(
&self,
subscription_ids: &[u32],
send_initial_values: bool,
) -> Result<Vec<TransferResult>, StatusCode>;
fn delete_subscription(
&self,
subscription_id: u32,
) -> Result<StatusCode, StatusCode>;
fn delete_subscriptions(
&self,
subscription_ids: &[u32],
) -> Result<Vec<StatusCode>, StatusCode>;
}Required Methods§
Sourcefn create_subscription<CB>(
&self,
publishing_interval: f64,
lifetime_count: u32,
max_keep_alive_count: u32,
max_notifications_per_publish: u32,
priority: u8,
publishing_enabled: bool,
callback: CB,
) -> Result<u32, StatusCode>
fn create_subscription<CB>( &self, publishing_interval: f64, lifetime_count: u32, max_keep_alive_count: u32, max_notifications_per_publish: u32, priority: u8, publishing_enabled: bool, callback: CB, ) -> Result<u32, StatusCode>
Create a subscription by sending a CreateSubscriptionRequest to the server.
See OPC UA Part 4 - Services 5.13.2 for complete description of the service and error responses.
§Arguments
publishing_interval- The requested publishing interval defines the cyclic rate that the Subscription is being requested to return Notifications to the Client. This interval is expressed in milliseconds. This interval is represented by the publishing timer in the Subscription state table. The negotiated value for this parameter returned in the response is used as the default sampling interval for MonitoredItems assigned to this Subscription. If the requested value is 0 or negative, the server shall revise with the fastest supported publishing interval in milliseconds.lifetime_count- Requested lifetime count. The lifetime count shall be a minimum of three times the keep keep-alive count. When the publishing timer has expired this number of times without a Publish request being available to send a NotificationMessage, then the Subscription shall be deleted by the Server.max_keep_alive_count- Requested maximum keep-alive count. When the publishing timer has expired this number of times without requiring any NotificationMessage to be sent, the Subscription sends a keep-alive Message to the Client. The negotiated value for this parameter is returned in the response. If the requested value is 0, the server shall revise with the smallest supported keep-alive count.max_notifications_per_publish- The maximum number of notifications that the Client wishes to receive in a single Publish response. A value of zero indicates that there is no limit. The number of notifications per Publish is the sum of monitoredItems in the DataChangeNotification and events in the EventNotificationList.priority- Indicates the relative priority of the Subscription. When more than one Subscription needs to send Notifications, the Server should de-queue a Publish request to the Subscription with the highest priority number. For Subscriptions with equal priority the Server should de-queue Publish requests in a round-robin fashion. A Client that does not require special priority settings should set this value to zero.publishing_enabled- A boolean parameter with the following values -truepublishing is enabled for the Subscription,false, publishing is disabled for the Subscription. The value of this parameter does not affect the value of the monitoring mode Attribute of MonitoredItems.
§Returns
Ok(u32)- identifier for new subscriptionErr(StatusCode)- Status code reason for failure
Sourcefn modify_subscription(
&self,
subscription_id: u32,
publishing_interval: f64,
lifetime_count: u32,
max_keep_alive_count: u32,
max_notifications_per_publish: u32,
priority: u8,
) -> Result<(), StatusCode>
fn modify_subscription( &self, subscription_id: u32, publishing_interval: f64, lifetime_count: u32, max_keep_alive_count: u32, max_notifications_per_publish: u32, priority: u8, ) -> Result<(), StatusCode>
Modifies a subscription by sending a ModifySubscriptionRequest to the server.
See OPC UA Part 4 - Services 5.13.3 for complete description of the service and error responses.
§Arguments
subscription_id- subscription identifier returned fromcreate_subscription.
See create_subscription for description of other parameters
§Returns
Ok(())- SuccessErr(StatusCode)- Request failed, status code is the reason for failure
Sourcefn set_publishing_mode(
&self,
subscription_ids: &[u32],
publishing_enabled: bool,
) -> Result<Vec<StatusCode>, StatusCode>
fn set_publishing_mode( &self, subscription_ids: &[u32], publishing_enabled: bool, ) -> Result<Vec<StatusCode>, StatusCode>
Changes the publishing mode of subscriptions by sending a SetPublishingModeRequest to the server.
See OPC UA Part 4 - Services 5.13.4 for complete description of the service and error responses.
§Arguments
subscription_ids- one or more subscription identifiers.publishing_enabled- A boolean parameter with the following values -truepublishing is enabled for the Subscriptions,false, publishing is disabled for the Subscriptions.
§Returns
Ok(Vec<StatusCode>)- Service return code for the action for each id,GoodorBadSubscriptionIdInvalidErr(StatusCode)- Status code reason for failure
Sourcefn transfer_subscriptions(
&self,
subscription_ids: &[u32],
send_initial_values: bool,
) -> Result<Vec<TransferResult>, StatusCode>
fn transfer_subscriptions( &self, subscription_ids: &[u32], send_initial_values: bool, ) -> Result<Vec<TransferResult>, StatusCode>
Transfers Subscriptions and their MonitoredItems from one Session to another. For example, a Client may need to reopen a Session and then transfer its Subscriptions to that Session. It may also be used by one Client to take over a Subscription from another Client by transferring the Subscription to its Session.
See OPC UA Part 4 - Services 5.13.7 for complete description of the service and error responses.
subscription_ids- one or more subscription identifiers.send_initial_values- A boolean parameter with the following values -truethe first publish response shall contain the current values of all monitored items in the subscription,false, the first publish response shall contain only the value changes since the last publish response was sent.
§Returns
Ok(Vec<TransferResult>)- TheTransferResultfor each transfer subscription.Err(StatusCode)- Status code reason for failure
Sourcefn delete_subscription(
&self,
subscription_id: u32,
) -> Result<StatusCode, StatusCode>
fn delete_subscription( &self, subscription_id: u32, ) -> Result<StatusCode, StatusCode>
Deletes a subscription by sending a DeleteSubscriptionsRequest to the server.
See OPC UA Part 4 - Services 5.13.8 for complete description of the service and error responses.
§Arguments
subscription_id- subscription identifier returned fromcreate_subscription.
§Returns
Ok(StatusCode)- Service return code for the delete action,GoodorBadSubscriptionIdInvalidErr(StatusCode)- Status code reason for failure
Sourcefn delete_subscriptions(
&self,
subscription_ids: &[u32],
) -> Result<Vec<StatusCode>, StatusCode>
fn delete_subscriptions( &self, subscription_ids: &[u32], ) -> Result<Vec<StatusCode>, StatusCode>
Deletes subscriptions by sending a DeleteSubscriptionsRequest to the server with the list
of subscriptions to delete.
See OPC UA Part 4 - Services 5.13.8 for complete description of the service and error responses.
§Arguments
subscription_ids- List of subscription identifiers to delete.
§Returns
Ok(Vec<StatusCode>)- List of result for delete action on each id,GoodorBadSubscriptionIdInvalidThe size and order of the list matches the size and order of the input.Err(StatusCode)- Status code reason for failure
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.