pub(crate) fn push_input(
        &mut self,
        index: QueueIndex,
        msg: RequestOrResponse,
        canister_available_memory: i64,
        subnet_available_memory: &mut i64,
        own_subnet_type: SubnetType,
        input_queue_type: InputQueueType,
    ) -> 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 (&msg, &self.status) {
            // Requests and responses are both rejected when stopped.
            (_, CanisterStatus::Stopped { .. }) => {
                Err((StateError::CanisterStopped(self.canister_id()), msg))
            }

            // Requests (only) are rejected while stopping.
            (RequestOrResponse::Request(_), CanisterStatus::Stopping { .. }) => {
                Err((StateError::CanisterStopping(self.canister_id()), msg))
            }

            // Everything else is accepted iff there is available memory and queue slots.
            (_, CanisterStatus::Running { .. })
            | (RequestOrResponse::Response(_), CanisterStatus::Stopping { .. }) => push_input(
                &mut self.queues,
                index,
                msg,
                canister_available_memory,
                subnet_available_memory,
                own_subnet_type,
                input_queue_type,
            ),
        }
    }
/// 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 the maximum memory size and
/// cycles cost for sending the `Response` back. If it is a `Response`,
/// the protocol should have already reserved a slot and memory for it.
///
/// Updates `subnet_available_memory` to reflect any change in memory usage.
///
/// # Notes
///  * `Running` system states accept requests and responses.
///  * `Stopping` system states accept responses only.
///  * `Stopped` system states accept neither.
///
/// # Errors
///
/// On failure, returns the provided message along with a `StateError`:
///  * `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.
///  * `OutOfMemory` if the necessary memory reservation is larger than the
///    canister or subnet available memory.
///  * `CanisterStopping` if the canister is stopping and inducting a
///    `Request` was attempted.
///  * `CanisterStopped` if the canister is stopped.
///
/// # Panics
///
/// Panics if a `Response` message is pushed onto a queue that does not
/// already exist or does not have a reserved slot.
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 the maximum memory size and
cycles cost for sending the `Response` back. If it is a `Response`,
the protocol should have already reserved a slot and memory for it.

Updates `subnet_available_memory` to reflect any change in memory usage.
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 the maximum memory size and cycles cost for sending the ` Response ` back . If it is a ` Response ` the protocol should have already reserved a slot and memory for it . Updates ` subnet_available_memory ` to reflect any change in memory usage .
pub(crate) fn push_input(
        &mut self,
        index: QueueIndex,
        msg: RequestOrResponse,
        canister_available_memory: i64,
        subnet_available_memory: &mut i64,
        own_subnet_type: SubnetType,
        input_queue_type: InputQueueType,
    ) -> 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 (&msg, &self.status) {
            // Requests and responses are both rejected when stopped.
            (_, CanisterStatus::Stopped { .. }) => {
                Err((StateError::CanisterStopped(self.canister_id()), msg))
            }
            // Requests (only) are rejected while stopping.
            (RequestOrResponse::Request(_), CanisterStatus::Stopping { .. }) => {
                Err((StateError::CanisterStopping(self.canister_id()), msg))
            }
            // Everything else is accepted iff there is available memory and queue slots.
            (_, CanisterStatus::Running { .. })
            | (RequestOrResponse::Response(_), CanisterStatus::Stopping { .. }) => push_input(
                &mut self.queues,
                index,
                msg,
                canister_available_memory,
                subnet_available_memory,
                own_subnet_type,
                input_queue_type,
            ),
        }
    }
pub ( crate ) fn push_input ( & mut self , index : QueueIndex , msg : RequestOrResponse , canister_available_memory : i64 , subnet_available_memory : & mut i64 , own_subnet_type : SubnetType , input_queue_type : InputQueueType , ) -> Result < ( ) , ( StateError , RequestOrResponse ) > { assert_eq ! ( msg receiver ( ) self canister_id " " self canister_id msg receiver ( ) ) ; match ( & msg , & self . status ) { // Requests and responses are both rejected when stopped. ( _ , CanisterStatus :: Stopped { .. } ) => { Err ( ( StateError :: CanisterStopped ( self . canister_id ( ) ) , msg ) ) } // Requests (only) are rejected while stopping. ( RequestOrResponse :: Request ( _ ) , CanisterStatus :: Stopping { .. } ) => { Err ( ( StateError :: CanisterStopping ( self . canister_id ( ) ) , msg ) ) } // Everything else is accepted iff there is available memory and queue slots. ( _ , CanisterStatus :: Running { .. } ) | ( RequestOrResponse :: Response ( _ ) , CanisterStatus :: Stopping { .. } ) => push_input ( & mut self . queues , index , msg , canister_available_memory , subnet_available_memory , own_subnet_type , input_queue_type , ) , } }
Pushes a `RequestOrResponse` into the induction pool.
Pushes a ` RequestOrResponse ` into the induction pool .
&mut self
index
QueueIndex
msg
RequestOrResponse
canister_available_memory
i64
subnet_available_memory
&mut i64
own_subnet_type
SubnetType
input_queue_type
InputQueueType
&mut self
index
QueueIndex
msg
RequestOrResponse
canister_available_memory
i64
subnet_available_memory
&mut i64
own_subnet_type
SubnetType
input_queue_type
InputQueueType
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
On failure, returns the provided message along with a `StateError`:
`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.
`OutOfMemory` if the necessary memory reservation is larger than the
canister or subnet available memory.
`CanisterStopping` if the canister is stopping and inducting a
`Request` was attempted.
`CanisterStopped` if the canister is stopped.
On failure returns the provided message along with a ` StateError ` : ` 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 . ` OutOfMemory ` if the necessary memory reservation is larger than the canister or subnet available memory . ` CanisterStopping ` if the canister is stopping and inducting a ` Request ` was attempted . ` CanisterStopped ` if the canister is stopped .
panics
Panics if a `Response` message is pushed onto a queue that does not
already exist or does not have a reserved slot.
Panics if a ` Response ` message is pushed onto a queue that does not already exist or does not have a reserved slot .