Skip to main content

vox_core/
into_conduit.rs

1use vox_types::{Link, MsgFamily};
2
3use crate::BareConduit;
4
5/// Converts a value into a [`vox_types::Conduit`].
6///
7/// Implemented for:
8/// - [`BareConduit`] → identity (pass-through)
9/// - [`crate::StableConduit`] → identity (pass-through)
10///
11/// This allows [`crate::Session`] connection handling methods
12/// to accept already-constructed conduits without additional wrapping.
13pub trait IntoConduit {
14    /// The conduit type produced by this conversion.
15    type Conduit;
16
17    /// Convert into a conduit.
18    fn into_conduit(self) -> Self::Conduit;
19}
20
21/// [`BareConduit`] passes through unchanged.
22impl<F: MsgFamily, L: Link> IntoConduit for BareConduit<F, L> {
23    type Conduit = BareConduit<F, L>;
24
25    fn into_conduit(self) -> Self::Conduit {
26        self
27    }
28}
29
30/// [`crate::StableConduit`] passes through unchanged.
31#[cfg(not(target_arch = "wasm32"))]
32impl<F: MsgFamily, LS: crate::LinkSource> IntoConduit for crate::StableConduit<F, LS> {
33    type Conduit = crate::StableConduit<F, LS>;
34
35    fn into_conduit(self) -> Self::Conduit {
36        self
37    }
38}