pub fn spin_once<'node>(node: &'node Node, timeout: i64) -> Result<(), WaitSetErrorResponse> {
    let number_of_subscriptions = node.subscriptions.len();
    let number_of_guard_conditions = 0;
    let number_of_timers = 0;
    let number_of_clients = 0;
    let number_of_services = 0;
    let number_of_events = 0;

    let context = &mut *node.context.lock();

    let mut wait_set = WaitSet::new(
        number_of_subscriptions,
        number_of_guard_conditions,
        number_of_timers,
        number_of_clients,
        number_of_services,
        number_of_events,
        context,
    )?;

    for subscription in &node.subscriptions {
        match wait_set.add_subscription(subscription) {
            Ok(()) => (),
            Err(WaitSetErrorResponse::DroppedSubscription) => (),
            Err(err) => return Err(err),
        };
    }

    wait_set.wait(timeout)?;
    for subscription in &node.subscriptions {
        if let Some(subscription) = subscription.upgrade() {
            let mut message = subscription.create_message();
            let result = subscription.take(&mut *message).unwrap();
            if result {
                subscription.callback_fn(message);
            }
        }
    }

    Ok(())
}
/// Main function for waiting.
///
/// Following is a schematic representation of the interation of [`spin_once`] with ROS RCL FFI
///
/// +---------------------------------------+
/// |                                       |
/// |   rcl_get_zero_initialized_wait_set   |
/// |                                       |
/// +-----------------+---------------------+
///                   |
///                   |
///        +----------v----------+
///        |  rcl_wait_set_init  |
///        +----------+----------+
///                   |
///        +----------v----------+
///        |  rcl_wait_set_clear |
///        +----------+----------+
///                   |
///   +---------------v------------------+   <---+
///   |rcl_wait_set_add_{subscription,   |       | for all subscriptions,
///   |                  guard_condition |       | services, etc.
///   |                  timer,          |       |
///   |                  client,         |       |
///   |                  service,        |       |
///   |                  e^ent}          |       |
///   +---------------+------------------+ +-----+
///                   |
///         +---------v----------+
///         |     rcl_wait       |
///         +---------+----------+
///                   |
///         +---------v----------+
///         | rcl_wait_set_fini  |
///         +--------------------+
///
///
Main function for waiting.
Following is a schematic representation of the interation of [`spin_once`] with ROS RCL FFI


Main function for waiting . Following is a schematic representation of the interation of [ ` spin_once ` ] with ROS RCL FFI
pub fn spin_once<'node>(node: &'node Node, timeout: i64) -> Result<(), WaitSetErrorResponse> {
    let number_of_subscriptions = node.subscriptions.len();
    let number_of_guard_conditions = 0;
    let number_of_timers = 0;
    let number_of_clients = 0;
    let number_of_services = 0;
    let number_of_events = 0;
    let context = &mut *node.context.lock();
    let mut wait_set = WaitSet::new(
        number_of_subscriptions,
        number_of_guard_conditions,
        number_of_timers,
        number_of_clients,
        number_of_services,
        number_of_events,
        context,
    )?;
    for subscription in &node.subscriptions {
        match wait_set.add_subscription(subscription) {
            Ok(()) => (),
            Err(WaitSetErrorResponse::DroppedSubscription) => (),
            Err(err) => return Err(err),
        };
    }
    wait_set.wait(timeout)?;
    for subscription in &node.subscriptions {
        if let Some(subscription) = subscription.upgrade() {
            let mut message = subscription.create_message();
            let result = subscription.take(&mut *message).unwrap();
            if result {
                subscription.callback_fn(message);
            }
        }
    }
    Ok(())
}
pub fn spin_once < ' node > ( node : & ' node Node , timeout : i64 ) -> Result < ( ) , WaitSetErrorResponse > { let number_of_subscriptions = node . subscriptions . len ( ) ; let number_of_guard_conditions = 0 ; let number_of_timers = 0 ; let number_of_clients = 0 ; let number_of_services = 0 ; let number_of_events = 0 ; let context = & mut * node . context . lock ( ) ; let mut wait_set = WaitSet :: new ( number_of_subscriptions , number_of_guard_conditions , number_of_timers , number_of_clients , number_of_services , number_of_events , context , ) ? ; for subscription in & node . subscriptions { match wait_set . add_subscription ( subscription ) { Ok ( ( ) ) => ( ) , Err ( WaitSetErrorResponse :: DroppedSubscription ) => ( ) , Err ( err ) => return Err ( err ) , } ; } wait_set . wait ( timeout ) ? ; for subscription in & node . subscriptions { if let Some ( subscription ) = subscription . upgrade ( ) { let mut message = subscription . create_message ( ) ; let result = subscription . take ( & mut * message ) . unwrap ( ) ; if result { subscription . callback_fn ( message ) ; } } } Ok ( ( ) ) }
Main function for waiting.
Main function for waiting .
node
&'node Node
timeout
i64
node
&'node Node
timeout
i64