Skip to main content

subscribe_actions

Function subscribe_actions 

Source
pub async fn subscribe_actions<F, Fut>(
    rpc_endpoint: &str,
    on_notification: F,
) -> Result<ActionSubscriptionHandle, SubscriptionError>
where F: Fn(ActionResultNotification) -> Fut + Send + Sync + 'static, Fut: Future<Output = ()> + Send + 'static,
Expand description

Subscribe to the results of the session’s scheduled actions.

The session runs the actions registered at creation; each result arrives as an ActionResultNotification. Every action shares this one stream: tell them apart by action_index or label. Callbacks run one at a time, in order. The stream ends cleanly when the server finishes it. Never reconnects: a dropped WebSocket ends the stream with SubscriptionRuntimeError::Closed.

§Errors

SubscriptionError if the subscription cannot be started.

§Example

use simulator_client::{ManagedBacktestSession, subscribe_actions};

let handle = subscribe_actions(
    &session.session_info().rpc_endpoint,
    |result| async move {
        println!("slot={} label={:?}", result.slot, result.label);
    },
)
.await?;

handle.shutdown().await?;