cat_gateway/service/common/objects/legacy/
fragments_batch.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! Defines API schemas for fragment batch types.

use poem_openapi::{types::Example, NewType, Object};
use serde::Deserialize;

#[derive(NewType, Deserialize)]
/// Hex-encoded fragment's bytes.
pub(crate) struct FragmentDef(String);

#[derive(Object, Deserialize)]
#[oai(example = true)]
/// Batch of hex-encoded fragments.
pub(crate) struct FragmentsBatch {
    /// Fragments are processed sequentially. If this is true, processing is
    /// stopped after the first error occurs.
    pub fail_fast: bool,
    /// Array of hex-encoded fragments bytes.
    // TODO(bkioshn): https://github.com/input-output-hk/catalyst-voices/issues/239
    #[oai(validator(
        max_items = "100",
        max_length = 66,
        min_length = 66,
        pattern = "0x[0-9a-f]{64}"
    ))]
    pub fragments: Vec<FragmentDef>,
}

impl Example for FragmentsBatch {
    fn example() -> Self {
        Self {
            fail_fast: false,
            fragments: vec![],
        }
    }
}