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
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Configure the transports for of your [`Ditto`] instance.

use_prelude!();

pub(crate) mod connection_request_handler;
pub(crate) mod presence;
pub(crate) mod presence_observer;
pub(crate) mod sync;
pub(crate) mod sync_state;
pub(crate) mod transport_config;
pub(crate) mod v2;
pub(crate) mod v3;

pub use presence::Presence;
pub use presence_observer::PresenceObserver;
pub use sync::TransportSync;
pub use transport_config::{
    BluetoothLEConfig, Connect, Global, HttpListenConfig, LanConfig, Listen, PeerToPeer,
    TcpListenConfig, TransportConfig,
};
pub use v3::{Peer, PresenceGraph, PresenceOs};

#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ConnectionType {
    Bluetooth,
    AccessPoint,
    P2PWiFi,
    WebSocket,
    #[doc(hidden)]
    Unknown,
}

impl ConnectionType {
    fn from_ffi(ffi: ::ffi_sdk::ConnectionType) -> Self {
        match ffi {
            ::ffi_sdk::ConnectionType::Bluetooth => Self::Bluetooth,
            ::ffi_sdk::ConnectionType::AccessPoint => Self::AccessPoint,
            ::ffi_sdk::ConnectionType::P2PWiFi => Self::P2PWiFi,
            ::ffi_sdk::ConnectionType::WebSocket => Self::WebSocket,
            #[allow(unreachable_patterns)]
            _ => {
                ::log::debug!("got unknown `ConnectionType`: {ffi:?}");
                Self::Unknown
            }
        }
    }
}