async fn peek_lock_message2(
    http_client: &Arc<dyn HttpClient>,
    namespace: &str,
    queue: &str,
    policy_name: &str,
    signing_key: &hmac::Key,
    lock_expiry: Option<Duration>,
) -> Result<PeekLockResponse, Error> {
    let url = craft_peek_lock_url(namespace, queue, lock_expiry)?;

    let req = prepare_request(
        &url.to_string(),
        Method::POST,
        None,
        policy_name,
        signing_key,
    )?;

    let res = http_client.execute_request(req).await?;

    let status = res.status();
    let lock_location: String = match res.headers().get("Location") {
        Some(header_value) => header_value
            .to_str()
            .context(
                ErrorKind::DataConversion,
                "failed to get lock location from header",
            )?
            .to_owned(),
        _ => "".to_owned(),
    };
    let body = body_bytes_to_utf8(res.body())?;

    Ok(PeekLockResponse {
        body,
        lock_location,
        status,
        http_client: http_client.clone(),
        policy_name: policy_name.to_owned(),
        signing_key: signing_key.to_owned(),
    })
}
/// Non-destructively read a message but track it
///
/// Note: This function returns a `PeekLockResponse`
/// that contains a helper `delete_message` function.
Non-destructively read a message but track it
Note: This function returns a `PeekLockResponse`
that contains a helper `delete_message` function.
Non - destructively read a message but track it Note : This function returns a ` PeekLockResponse ` that contains a helper ` delete_message ` function .
async fn peek_lock_message2(
    http_client: &Arc<dyn HttpClient>,
    namespace: &str,
    queue: &str,
    policy_name: &str,
    signing_key: &hmac::Key,
    lock_expiry: Option<Duration>,
) -> Result<PeekLockResponse, Error> {
    let url = craft_peek_lock_url(namespace, queue, lock_expiry)?;
    let req = prepare_request(
        &url.to_string(),
        Method::POST,
        None,
        policy_name,
        signing_key,
    )?;
    let res = http_client.execute_request(req).await?;
    let status = res.status();
    let lock_location: String = match res.headers().get("Location") {
        Some(header_value) => header_value
            .to_str()
            .context(
                ErrorKind::DataConversion,
                "failed to get lock location from header",
            )?
            .to_owned(),
        _ => "".to_owned(),
    };
    let body = body_bytes_to_utf8(res.body())?;
    Ok(PeekLockResponse {
        body,
        lock_location,
        status,
        http_client: http_client.clone(),
        policy_name: policy_name.to_owned(),
        signing_key: signing_key.to_owned(),
    })
}
async fn peek_lock_message2 ( http_client : & Arc < dyn HttpClient > , namespace : & str , queue : & str , policy_name : & str , signing_key : & hmac :: Key , lock_expiry : Option < Duration > , ) -> Result < PeekLockResponse , Error > { let url = craft_peek_lock_url ( namespace , queue , lock_expiry ) ? ; let req = prepare_request ( & url . to_string ( ) , Method :: POST , None , policy_name , signing_key , ) ? ; let res = http_client . execute_request ( req ) . await ? ; let status = res . status ( ) ; let lock_location : String = match res . headers ( ) . get ( " " ) { Some ( header_value ) => header_value . to_str ( ) . context ( ErrorKind :: DataConversion , " " , ) ? . to_owned ( ) , _ => " " . to_owned ( ) , } ; let body = body_bytes_to_utf8 ( res . body ( ) ) ? ; Ok ( PeekLockResponse { body , lock_location , status , http_client : http_client . clone ( ) , policy_name : policy_name . to_owned ( ) , signing_key : signing_key . to_owned ( ) , } ) }
Non-destructively read a message but track it
Note: This function returns a `PeekLockResponse`
that contains a helper `delete_message` function.
Non - destructively read a message but track it Note : This function returns a ` PeekLockResponse ` that contains a helper ` delete_message ` function .
http_client
&Arc<dyn HttpClient>
namespace
&str
queue
&str
policy_name
&str
signing_key
&hmac::Key
lock_expiry
Option<Duration>