pub async fn stop_instance(
        model: Arc<Model>,
        realm: Arc<Realm>,
        state: Option<&mut RealmState>,
        shut_down: bool,
    ) -> Result<(bool, Vec<Notification>), ModelError> {
        let (was_running, nfs) = {
            let was_running = {
                let mut execution = realm.lock_execution().await;
                let was_running = execution.runtime.is_some();
                if let Some(runtime) = &mut execution.runtime {
                    if let Some(controller) = &runtime.controller {
                        // Tell the controller to stop the component, but
                        // ignore any FIDL error since we will proceed with
                        // our shutdown procedure even if the channel is closed.
                        match controller.stop() {
                            Ok(()) | Err(fidl::Error::ClientChannelClosed(_)) => {}
                            Err(e) => {
                                return Err(ModelError::RunnerCommunicationError {
                                    moniker: realm.abs_moniker.clone(),
                                    operation: "stop".to_string(),
                                    err: clonable_error::ClonableError::from(failure::Error::from(
                                        e,
                                    )),
                                });
                            }
                        }
                    }

                    // component runner closed the control channel, shutdown is
                    // complete
                    runtime.wait_on_channel_close().await;
                }

                execution.runtime = None;
                execution.shut_down |= shut_down;
                was_running
            };
            let nfs = if let Some(state) = state {
                // When the realm is stopped, any child instances in transient collections must be
                // destroyed.
                Self::destroy_transient_children(model.clone(), realm.clone(), state).await?
            } else {
                vec![]
            };
            (was_running, nfs)
        };
        Ok((was_running, nfs))
    }
/// Performs the stop protocol for this component instance.
///
/// Returns whether the instance was already running, and notifications to wait on for
/// transient children to be destroyed.
///
/// REQUIRES: All dependents have already been stopped.
Performs the stop protocol for this component instance.
Returns whether the instance was already running, and notifications to wait on for
transient children to be destroyed.

All dependents have already been stopped.
Performs the stop protocol for this component instance . Returns whether the instance was already running and notifications to wait on for transient children to be destroyed . All dependents have already been stopped .
pub async fn stop_instance(
        model: Arc<Model>,
        realm: Arc<Realm>,
        state: Option<&mut RealmState>,
        shut_down: bool,
    ) -> Result<(bool, Vec<Notification>), ModelError> {
        let (was_running, nfs) = {
            let was_running = {
                let mut execution = realm.lock_execution().await;
                let was_running = execution.runtime.is_some();
                if let Some(runtime) = &mut execution.runtime {
                    if let Some(controller) = &runtime.controller {
                        // Tell the controller to stop the component, but
                        // ignore any FIDL error since we will proceed with
                        // our shutdown procedure even if the channel is closed.
                        match controller.stop() {
                            Ok(()) | Err(fidl::Error::ClientChannelClosed(_)) => {}
                            Err(e) => {
                                return Err(ModelError::RunnerCommunicationError {
                                    moniker: realm.abs_moniker.clone(),
                                    operation: "stop".to_string(),
                                    err: clonable_error::ClonableError::from(failure::Error::from(
                                        e,
                                    )),
                                });
                            }
                        }
                    }
                    // component runner closed the control channel, shutdown is
                    // complete
                    runtime.wait_on_channel_close().await;
                }
                execution.runtime = None;
                execution.shut_down |= shut_down;
                was_running
            };
            let nfs = if let Some(state) = state {
                // When the realm is stopped, any child instances in transient collections must be
                // destroyed.
                Self::destroy_transient_children(model.clone(), realm.clone(), state).await?
            } else {
                vec![]
            };
            (was_running, nfs)
        };
        Ok((was_running, nfs))
    }
pub async fn stop_instance ( model : Arc < Model > , realm : Arc < Realm > , state : Option < & mut RealmState > , shut_down : bool , ) -> Result < ( bool , Vec < Notification > ) , ModelError > { let ( was_running , nfs ) = { let was_running = { let mut execution = realm . lock_execution ( ) . await ; let was_running = execution . runtime . is_some ( ) ; if let Some ( runtime ) = & mut execution . runtime { if let Some ( controller ) = & runtime . controller { // Tell the controller to stop the component, but // ignore any FIDL error since we will proceed with // our shutdown procedure even if the channel is closed. match controller . stop ( ) { Ok ( ( ) ) | Err ( fidl :: Error :: ClientChannelClosed ( _ ) ) => { } Err ( e ) => { return Err ( ModelError :: RunnerCommunicationError { moniker : realm . abs_moniker . clone ( ) , operation : " " . to_string ( ) , err : clonable_error :: ClonableError :: from ( failure :: Error :: from ( e , ) ) , } ) ; } } } // component runner closed the control channel, shutdown is // complete runtime . wait_on_channel_close ( ) . await ; } execution . runtime = None ; execution . shut_down |= shut_down ; was_running } ; let nfs = if let Some ( state ) = state { // When the realm is stopped, any child instances in transient collections must be // destroyed. Self :: destroy_transient_children ( model . clone ( ) , realm . clone ( ) , state ) . await ? } else { vec ! [ ] } ; ( was_running , nfs ) } ; Ok ( ( was_running , nfs ) ) }
Performs the stop protocol for this component instance.
Performs the stop protocol for this component instance .
model
Arc<Model>
realm
Arc<Realm>
state
Option<&mut RealmState>
shut_down
bool