request_response/
data_source.rs

1//! This file contains the [`DataSource`] trait. This trait allows the [`RequestResponseProtocol`]
2//! to calculate/derive a response for a specific request. In the confirmation layer the implementer
3//! would be something like a [`FeeMerkleTree`] for fee catchup
4
5use anyhow::Result;
6use async_trait::async_trait;
7
8use super::request::Request;
9
10/// The trait that allows the [`RequestResponseProtocol`] to calculate/derive a response for a specific request
11#[async_trait]
12pub trait DataSource<R: Request>: Send + Sync + 'static + Clone {
13    /// Calculate/derive the response for a specific request
14    async fn derive_response_for(&self, request: &R) -> Result<R::Response>;
15}