use serde::{Deserialize, Serialize};
pub type PaginatedResult<T> = crate::data::query::PageResult<T>;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChangeResultModel<T> {
pub affected_count: usize,
pub affected_entities: Vec<T>,
}
impl<T> ChangeResultModel<T> {
pub fn new(entities: Vec<T>) -> Self {
Self {
affected_count: entities.len(),
affected_entities: entities,
}
}
pub fn empty() -> Self {
Self {
affected_count: 0,
affected_entities: Vec::new(),
}
}
}
#[derive(Debug, Clone)]
pub struct EntityProjection {
pub fields: Vec<String>,
}
impl EntityProjection {
pub fn new(fields: Vec<String>) -> Self { Self { fields } }
pub fn all() -> Self { Self { fields: vec!["*".to_string()] } }
}
#[derive(Debug, Clone, Copy)]
pub enum Position {
Asc,
Desc,
}
pub trait StatelessChangeEffector<E>: Send + Sync {
fn apply(&self, entity: &mut E) -> bool;
}
#[async_trait::async_trait]
pub trait QueueConsumerHandler<T, R>: Send + Sync {
async fn handle(&self, data: T, redelivered: bool) -> anyhow::Result<R>;
}