pub fn push_input(
        &mut self,
        index: QueueIndex,
        msg: RequestOrResponse,
    ) -> Result<(), (StateError, RequestOrResponse)> {
        assert_eq!(
            msg.receiver(),
            self.canister_id,
            "Expected `RequestOrResponse` to be targeted to canister id {}, but instead got {}",
            self.canister_id,
            msg.receiver()
        );
        match self.status {
            CanisterStatus::Running { .. } => self.queues.push_input(index, msg),
            CanisterStatus::Stopping { .. } => {
                // Responses are accepted and requests are rejected.
                match msg {
                    RequestOrResponse::Request(req) => Err((
                        StateError::CanisterStopping(self.canister_id()),
                        RequestOrResponse::Request(req),
                    )),
                    RequestOrResponse::Response(response) => self
                        .queues
                        .push_input(index, RequestOrResponse::Response(response)),
                }
            }
            CanisterStatus::Stopped => {
                // Requests and responses are both rejected.
                Err((StateError::CanisterStopped(self.canister_id()), msg))
            }
        }
    }
/// Pushes a `RequestOrResponse` into the induction pool.
///
/// If the message is a `Request`, reserves a slot in the corresponding
/// output queue for the eventual response and reserves the maximum cycles
/// cost for sending the `Response` back. If it is a `Response`, the
/// protocol should have already reserved a slot for it.
///
/// # Notes
///  * `Running` system states accept requests and responses.
///  * `Stopping` system states accept responses only.
///  * `Stopped` system states accept neither.
///
/// # Errors
///
/// Returns a `StateError` along with the provided message:
///  * `QueueFull` if either the input queue or the matching output queue is
///    full when pushing a `Request` message.
///  * `CanisterOutOfCycles` if the canister does not have enough cycles to
///    be
///  * `CanisterStopping` if the canister is stopping and inducting a
///    `Request` is attempted.
///  * `CanisterStopped` if the canister is stopped.
///
/// # Panics
///
/// Panics if a `Response` message is pushed into a queue that does not
/// already exist or there is no reserved slot in the queue.
///
/// Warning! this is only exposed for test purposes and should not be used
/// outside of this crate.
Pushes a `RequestOrResponse` into the induction pool.
If the message is a `Request`, reserves a slot in the corresponding
output queue for the eventual response and reserves the maximum cycles
cost for sending the `Response` back. If it is a `Response`, the
protocol should have already reserved a slot for it.
Pushes a ` RequestOrResponse ` into the induction pool . If the message is a ` Request ` reserves a slot in the corresponding output queue for the eventual response and reserves the maximum cycles cost for sending the ` Response ` back . If it is a ` Response ` the protocol should have already reserved a slot for it .
pub fn push_input(
        &mut self,
        index: QueueIndex,
        msg: RequestOrResponse,
    ) -> Result<(), (StateError, RequestOrResponse)> {
        assert_eq!(
            msg.receiver(),
            self.canister_id,
            "Expected `RequestOrResponse` to be targeted to canister id {}, but instead got {}",
            self.canister_id,
            msg.receiver()
        );
        match self.status {
            CanisterStatus::Running { .. } => self.queues.push_input(index, msg),
            CanisterStatus::Stopping { .. } => {
                // Responses are accepted and requests are rejected.
                match msg {
                    RequestOrResponse::Request(req) => Err((
                        StateError::CanisterStopping(self.canister_id()),
                        RequestOrResponse::Request(req),
                    )),
                    RequestOrResponse::Response(response) => self
                        .queues
                        .push_input(index, RequestOrResponse::Response(response)),
                }
            }
            CanisterStatus::Stopped => {
                // Requests and responses are both rejected.
                Err((StateError::CanisterStopped(self.canister_id()), msg))
            }
        }
    }
pub fn push_input ( & mut self , index : QueueIndex , msg : RequestOrResponse , ) -> Result < ( ) , ( StateError , RequestOrResponse ) > { assert_eq ! ( msg receiver ( ) self canister_id " " self canister_id msg receiver ( ) ) ; match self . status { CanisterStatus :: Running { .. } => self . queues . push_input ( index , msg ) , CanisterStatus :: Stopping { .. } => { // Responses are accepted and requests are rejected. match msg { RequestOrResponse :: Request ( req ) => Err ( ( StateError :: CanisterStopping ( self . canister_id ( ) ) , RequestOrResponse :: Request ( req ) , ) ) , RequestOrResponse :: Response ( response ) => self . queues . push_input ( index , RequestOrResponse :: Response ( response ) ) , } } CanisterStatus :: Stopped => { // Requests and responses are both rejected. Err ( ( StateError :: CanisterStopped ( self . canister_id ( ) ) , msg ) ) } } }
Pushes a `RequestOrResponse` into the induction pool.
Pushes a ` RequestOrResponse ` into the induction pool .
&mut self
index
QueueIndex
msg
RequestOrResponse
&mut self
index
QueueIndex
msg
RequestOrResponse
notes
`Running` system states accept requests and responses.
`Stopping` system states accept responses only.
`Stopped` system states accept neither.
` Running ` system states accept requests and responses . ` Stopping ` system states accept responses only . ` Stopped ` system states accept neither .
errors
Returns a `StateError` along with the provided message:
`QueueFull` if either the input queue or the matching output queue is
full when pushing a `Request` message.
`CanisterOutOfCycles` if the canister does not have enough cycles to
be
`CanisterStopping` if the canister is stopping and inducting a
`Request` is attempted.
`CanisterStopped` if the canister is stopped.
Returns a ` StateError ` along with the provided message : ` QueueFull ` if either the input queue or the matching output queue is full when pushing a ` Request ` message . ` CanisterOutOfCycles ` if the canister does not have enough cycles to be ` CanisterStopping ` if the canister is stopping and inducting a ` Request ` is attempted . ` CanisterStopped ` if the canister is stopped .
panics
Panics if a `Response` message is pushed into a queue that does not
already exist or there is no reserved slot in the queue.

Warning. this is only exposed for test purposes and should not be used
outside of this crate.
Panics if a ` Response ` message is pushed into a queue that does not already exist or there is no reserved slot in the queue . Warning . this is only exposed for test purposes and should not be used outside of this crate .