zksync_da_client/
lib.rs

1pub mod types;
2
3use std::fmt;
4
5use async_trait::async_trait;
6use types::{DAError, DispatchResponse, InclusionData};
7
8/// Trait that defines the interface for the data availability layer clients.
9#[async_trait]
10pub trait DataAvailabilityClient: Sync + Send + fmt::Debug {
11    /// Dispatches a blob to the data availability layer.
12    async fn dispatch_blob(
13        &self,
14        batch_number: u32,
15        data: Vec<u8>,
16    ) -> Result<DispatchResponse, DAError>;
17
18    /// Fetches the inclusion data for a given blob_id.
19    async fn get_inclusion_data(&self, blob_id: &str) -> Result<Option<InclusionData>, DAError>;
20
21    /// Clones the client and wraps it in a Box.
22    fn clone_boxed(&self) -> Box<dyn DataAvailabilityClient>;
23
24    /// Returns the maximum size of the blob (in bytes) that can be dispatched. None means no limit.
25    fn blob_size_limit(&self) -> Option<usize>;
26}
27
28impl Clone for Box<dyn DataAvailabilityClient> {
29    fn clone(&self) -> Box<dyn DataAvailabilityClient> {
30        self.clone_boxed()
31    }
32}