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
use itertools::Itertools;
use ydb_grpc::ydb_proto::topic::{Codec, SupportedCodecs};

#[derive(serde::Serialize, Clone)]
pub(crate) struct RawCodec {
    pub code: i32
}

impl RawCodec{
    fn is_raw(&self) -> bool{
        self.code == i32::from(Codec::Raw)
    }
}

#[derive(serde::Serialize, Clone, Default)]
pub(crate) struct RawSupportedCodecs {
    pub codecs: Vec<RawCodec>,
}

impl From<RawSupportedCodecs> for SupportedCodecs {
    fn from(value: RawSupportedCodecs) -> Self {
        Self {
            codecs: value
                .codecs
                .into_iter()
                .map(|x| x.code)
                .collect_vec(),
        }
    }
}