use std::{future::Future, pin::Pin};
use bytes::Bytes;
use rustack_sqs_model::{error::SqsError, operations::SqsOperation};
use crate::body::SqsResponseBody;
pub trait SqsHandler: Send + Sync + 'static {
fn handle_operation(
&self,
op: SqsOperation,
body: Bytes,
) -> Pin<Box<dyn Future<Output = Result<http::Response<SqsResponseBody>, SqsError>> + Send>>;
}
pub async fn dispatch_operation<H: SqsHandler>(
handler: &H,
op: SqsOperation,
body: Bytes,
) -> Result<http::Response<SqsResponseBody>, SqsError> {
tracing::debug!(operation = %op, "dispatching SQS operation");
handler.handle_operation(op, body).await
}