hyperstack_server/
mutation_batch.rs

1//! MutationBatch - Envelope type for propagating trace context across async boundaries.
2
3use hyperstack_interpreter::Mutation;
4use smallvec::SmallVec;
5use tracing::Span;
6
7/// Envelope type that carries mutations along with their originating span context.
8///
9/// This enables trace context propagation across the mpsc channel boundary
10/// from the Vixen parser to the Projector.
11#[derive(Debug)]
12pub struct MutationBatch {
13    /// The span from which these mutations originated
14    pub span: Span,
15    /// The mutations to process
16    pub mutations: SmallVec<[Mutation; 6]>,
17}
18
19impl MutationBatch {
20    pub fn new(mutations: SmallVec<[Mutation; 6]>) -> Self {
21        Self {
22            span: Span::current(),
23            mutations,
24        }
25    }
26
27    pub fn with_span(span: Span, mutations: SmallVec<[Mutation; 6]>) -> Self {
28        Self { span, mutations }
29    }
30
31    pub fn len(&self) -> usize {
32        self.mutations.len()
33    }
34
35    pub fn is_empty(&self) -> bool {
36        self.mutations.is_empty()
37    }
38}