pub async fn call_and_wait<W: Waiter>(&self, mut waiter: W) -> Result<Vec<u8>, AgentError> {
        let request_id = self
            .agent
            .update_raw(
                &self.canister_id,
                self.method_name.as_str(),
                self.arg.as_slice(),
                self.ingress_expiry_datetime,
            )
            .await?;
        waiter.start();
        let mut request_accepted = false;
        loop {
            match self.agent.request_status_raw(&request_id).await? {
                RequestStatusResponse::Replied {
                    reply: Replied::CallReplied(arg),
                } => return Ok(arg),
                RequestStatusResponse::Rejected {
                    reject_code,
                    reject_message,
                } => {
                    return Err(AgentError::ReplicaError {
                        reject_code,
                        reject_message,
                    })
                }
                RequestStatusResponse::Unknown => (),
                RequestStatusResponse::Received | RequestStatusResponse::Processing => {
                    // The system will return Unknown until the request is accepted
                    // and we generally cannot know how long that will take.
                    // State transitions between Received and Processing may be
                    // instantaneous. Therefore, once we know the request is accepted,
                    // we restart the waiter so the request does not time out.
                    if !request_accepted {
                        waiter
                            .restart()
                            .map_err(|_| AgentError::WaiterRestartError())?;
                        request_accepted = true;
                    }
                }
                RequestStatusResponse::Done => {
                    return Err(AgentError::RequestStatusDoneNoReply(String::from(
                        request_id,
                    )))
                }
            };

            waiter
                .wait()
                .map_err(|_| AgentError::TimeoutWaitingForResponse())?;
        }
    }
/// Make an update call. This will call request_status on the RequestId in a loop and return
/// the response as a byte vector.
Make an update call. This will call request_status on the RequestId in a loop and return
the response as a byte vector.
Make an update call . This will call request_status on the RequestId in a loop and return the response as a byte vector .
pub async fn call_and_wait<W: Waiter>(&self, mut waiter: W) -> Result<Vec<u8>, AgentError> {
        let request_id = self
            .agent
            .update_raw(
                &self.canister_id,
                self.method_name.as_str(),
                self.arg.as_slice(),
                self.ingress_expiry_datetime,
            )
            .await?;
        waiter.start();
        let mut request_accepted = false;
        loop {
            match self.agent.request_status_raw(&request_id).await? {
                RequestStatusResponse::Replied {
                    reply: Replied::CallReplied(arg),
                } => return Ok(arg),
                RequestStatusResponse::Rejected {
                    reject_code,
                    reject_message,
                } => {
                    return Err(AgentError::ReplicaError {
                        reject_code,
                        reject_message,
                    })
                }
                RequestStatusResponse::Unknown => (),
                RequestStatusResponse::Received | RequestStatusResponse::Processing => {
                    // The system will return Unknown until the request is accepted
                    // and we generally cannot know how long that will take.
                    // State transitions between Received and Processing may be
                    // instantaneous. Therefore, once we know the request is accepted,
                    // we restart the waiter so the request does not time out.
                    if !request_accepted {
                        waiter
                            .restart()
                            .map_err(|_| AgentError::WaiterRestartError())?;
                        request_accepted = true;
                    }
                }
                RequestStatusResponse::Done => {
                    return Err(AgentError::RequestStatusDoneNoReply(String::from(
                        request_id,
                    )))
                }
            };
            waiter
                .wait()
                .map_err(|_| AgentError::TimeoutWaitingForResponse())?;
        }
    }
pub async fn call_and_wait < W : Waiter > ( & self , mut waiter : W ) -> Result < Vec < u8 > , AgentError > { let request_id = self . agent . update_raw ( & self . canister_id , self . method_name . as_str ( ) , self . arg . as_slice ( ) , self . ingress_expiry_datetime , ) . await ? ; waiter . start ( ) ; let mut request_accepted = false ; loop { match self . agent . request_status_raw ( & request_id ) . await ? { RequestStatusResponse :: Replied { reply : Replied :: CallReplied ( arg ) , } => return Ok ( arg ) , RequestStatusResponse :: Rejected { reject_code , reject_message , } => { return Err ( AgentError :: ReplicaError { reject_code , reject_message , } ) } RequestStatusResponse :: Unknown => ( ) , RequestStatusResponse :: Received | RequestStatusResponse :: Processing => { // The system will return Unknown until the request is accepted // and we generally cannot know how long that will take. // State transitions between Received and Processing may be // instantaneous. Therefore, once we know the request is accepted, // we restart the waiter so the request does not time out. if ! request_accepted { waiter . restart ( ) . map_err ( | _ | AgentError :: WaiterRestartError ( ) ) ? ; request_accepted = true ; } } RequestStatusResponse :: Done => { return Err ( AgentError :: RequestStatusDoneNoReply ( String :: from ( request_id , ) ) ) } } ; waiter . wait ( ) . map_err ( | _ | AgentError :: TimeoutWaitingForResponse ( ) ) ? ; } }
Make an update call.
Make an update call .
&self
waiter
W