Skip to main content

melodium_share/
flow.rs

1use melodium_common::descriptor::Flow as CommonFlow;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
5#[serde(rename_all = "snake_case")]
6#[cfg_attr(feature = "webassembly", derive(tsify::Tsify))]
7#[cfg_attr(feature = "webassembly", tsify(into_wasm_abi, from_wasm_abi))]
8pub enum Flow {
9    Block,
10    Stream,
11}
12
13impl From<&CommonFlow> for Flow {
14    fn from(value: &CommonFlow) -> Self {
15        match value {
16            CommonFlow::Block => Flow::Block,
17            CommonFlow::Stream => Flow::Stream,
18        }
19    }
20}
21
22impl Into<CommonFlow> for Flow {
23    fn into(self) -> CommonFlow {
24        Into::into(&self)
25    }
26}
27
28impl Into<CommonFlow> for &Flow {
29    fn into(self) -> CommonFlow {
30        match self {
31            Flow::Block => CommonFlow::Block,
32            Flow::Stream => CommonFlow::Stream,
33        }
34    }
35}