use std::{marker::Send, sync::Arc}; use serde::Serialize; pub struct Response {} pub type Actions = Vec; #[derive(Clone, Debug, PartialEq, Eq)] pub enum Action { Ack, NackRequeue, NackDump, Publish(Arc), } #[derive(Debug, PartialEq, Eq)] pub struct QueueMsg { pub exchange: Option, pub routing_key: Option, pub mandatory: bool, pub immediate: bool, pub content_type: Option, pub content: Vec, } pub fn publish_serde_action( exchange: Option, routing_key: Option, msg: &T, ) -> Action { Action::Publish(Arc::new(QueueMsg { exchange, routing_key, mandatory: false, immediate: false, content_type: Some("application/json".to_owned()), content: serde_json::to_string(&msg).unwrap().into_bytes(), })) } pub trait SimpleWorker: Send { type J: Send; fn consumer(&mut self, job: &Self::J) -> impl std::future::Future; fn msg_to_job( &mut self, method: &str, headers: &Option, body: &[u8], ) -> impl std::future::Future>; }