Skip to main content

devsper_graph/
mutation.rs

1use devsper_core::GraphMutation;
2use tokio::sync::oneshot;
3
4/// A request to mutate the graph, with a response channel
5pub struct MutationRequest {
6    pub mutation: GraphMutation,
7    pub response: oneshot::Sender<MutationResult>,
8}
9
10/// Result of applying a mutation
11#[derive(Debug)]
12pub enum MutationResult {
13    Applied,
14    Rejected { reason: String },
15}
16
17impl MutationRequest {
18    pub fn new(mutation: GraphMutation) -> (Self, oneshot::Receiver<MutationResult>) {
19        let (tx, rx) = oneshot::channel();
20        (Self { mutation, response: tx }, rx)
21    }
22}