pub fn push_input(
        &mut self,
        index: QueueIndex,
        msg: RequestOrResponse,
    ) -> Result<(), (StateError, RequestOrResponse)> {
        let sender = msg.sender();
        let input_queue = match msg {
            RequestOrResponse::Request(_) => {
                let (input_queue, output_queue) = self.get_or_insert_queues(&sender);
                if let Err(e) = input_queue.check_has_slot() {
                    return Err((e, msg));
                }
                if let Err(e) = output_queue.reserve_slot() {
                    return Err((e, msg));
                }
                input_queue
            }
            RequestOrResponse::Response(_) => match self.input_queues.get_mut(&sender) {
                Some(queue) => queue,
                None => return Err((StateError::QueueFull { capacity: 0 }, msg)),
            },
        };
        let msg_size_bytes = InputQueue::message_size_bytes(&msg);
        input_queue.push(index, msg)?;

        // Add sender canister ID to the input schedule queue if it isn't already there.
        // Sender was not scheduled iff its input queue was empty before the push (i.e.
        // queue size is 1 after the push).
        if input_queue.num_messages() == 1 {
            self.input_schedule.push_back(sender);
        }

        self.input_queues_message_count += 1;
        self.input_queues_size_bytes += msg_size_bytes;
        debug_assert_eq!(
            Self::input_queues_stats(&self.input_queues),
            (
                self.input_queues_message_count,
                self.input_queues_size_bytes
            )
        );

        Ok(())
    }
/// Pushes a canister-to-canister message into the induction pool.
///
/// If the message is a `Request` this will also reserve a slot in the
/// corresponding output queue for the eventual response.
///
/// If the message is a `Response` the protocol will have already reserved
/// space for it, so the push cannot fail due to the input queue being
/// full.
///
/// # Errors
///
/// Returns a `StateError` along with the provided message:
///
///  * `QueueFull` if pushing a `Request` and the corresponding input or
///    output queues are full.
///
///  * `QueueFull` if pushing a `Response` and the receiving canister is not
///  expecting one.
Pushes a canister-to-canister message into the induction pool.
If the message is a `Request` this will also reserve a slot in the
corresponding output queue for the eventual response.

If the message is a `Response` the protocol will have already reserved
space for it, so the push cannot fail due to the input queue being
full.
Pushes a canister - to - canister message into the induction pool . If the message is a ` Request ` this will also reserve a slot in the corresponding output queue for the eventual response . If the message is a ` Response ` the protocol will have already reserved space for it so the push cannot fail due to the input queue being full .
pub fn push_input(
        &mut self,
        index: QueueIndex,
        msg: RequestOrResponse,
    ) -> Result<(), (StateError, RequestOrResponse)> {
        let sender = msg.sender();
        let input_queue = match msg {
            RequestOrResponse::Request(_) => {
                let (input_queue, output_queue) = self.get_or_insert_queues(&sender);
                if let Err(e) = input_queue.check_has_slot() {
                    return Err((e, msg));
                }
                if let Err(e) = output_queue.reserve_slot() {
                    return Err((e, msg));
                }
                input_queue
            }
            RequestOrResponse::Response(_) => match self.input_queues.get_mut(&sender) {
                Some(queue) => queue,
                None => return Err((StateError::QueueFull { capacity: 0 }, msg)),
            },
        };
        let msg_size_bytes = InputQueue::message_size_bytes(&msg);
        input_queue.push(index, msg)?;
        // Add sender canister ID to the input schedule queue if it isn't already there.
        // Sender was not scheduled iff its input queue was empty before the push (i.e.
        // queue size is 1 after the push).
        if input_queue.num_messages() == 1 {
            self.input_schedule.push_back(sender);
        }
        self.input_queues_message_count += 1;
        self.input_queues_size_bytes += msg_size_bytes;
        debug_assert_eq!(
            Self::input_queues_stats(&self.input_queues),
            (
                self.input_queues_message_count,
                self.input_queues_size_bytes
            )
        );
        Ok(())
    }
pub fn push_input ( & mut self , index : QueueIndex , msg : RequestOrResponse , ) -> Result < ( ) , ( StateError , RequestOrResponse ) > { let sender = msg . sender ( ) ; let input_queue = match msg { RequestOrResponse :: Request ( _ ) => { let ( input_queue , output_queue ) = self . get_or_insert_queues ( & sender ) ; if let Err ( e ) = input_queue . check_has_slot ( ) { return Err ( ( e , msg ) ) ; } if let Err ( e ) = output_queue . reserve_slot ( ) { return Err ( ( e , msg ) ) ; } input_queue } RequestOrResponse :: Response ( _ ) => match self . input_queues . get_mut ( & sender ) { Some ( queue ) => queue , None => return Err ( ( StateError :: QueueFull { capacity : 0 } , msg ) ) , } , } ; let msg_size_bytes = InputQueue :: message_size_bytes ( & msg ) ; input_queue . push ( index , msg ) ? ; // Add sender canister ID to the input schedule queue if it isn't already there. // Sender was not scheduled iff its input queue was empty before the push (i.e. // queue size is 1 after the push). if input_queue . num_messages ( ) == 1 { self . input_schedule . push_back ( sender ) ; } self . input_queues_message_count += 1 ; self . input_queues_size_bytes += msg_size_bytes ; debug_assert_eq ! ( Self input_queues_stats ( self input_queues ) ( self input_queues_message_count self input_queues_size_bytes ) ) ; Ok ( ( ) ) }
Pushes a canister-to-canister message into the induction pool.
Pushes a canister - to - canister message into the induction pool .
&mut self
index
QueueIndex
msg
RequestOrResponse
&mut self
index
QueueIndex
msg
RequestOrResponse
errors
Returns a `StateError` along with the provided message.

`QueueFull` if pushing a `Request` and the corresponding input or
output queues are full.

`QueueFull` if pushing a `Response` and the receiving canister is not
expecting one.
Returns a ` StateError ` along with the provided message . ` QueueFull ` if pushing a ` Request ` and the corresponding input or output queues are full . ` QueueFull ` if pushing a ` Response ` and the receiving canister is not expecting one .