nodedb_client/traits/core/marker.rs
1// SPDX-License-Identifier: Apache-2.0
2
3//! `NodeDbMarker` — platform-specific `Send + Sync` bound for the `NodeDb` trait.
4
5/// Marker bound for `NodeDb` and the futures it returns.
6///
7/// On native targets the bound is `Send + Sync` — matching the multi-thread
8/// Tokio runtime that backs both Origin and the desktop / mobile-FFI Lite
9/// callers. On `wasm32` the bound is empty: JS is single-threaded, so
10/// requiring `Send` on futures returned by the trait would force every
11/// `!Send` engine internal (redb transactions, `Rc<...>`, etc.) to be
12/// rewritten for no benefit.
13///
14/// The `#[async_trait]` attribute on the trait + each impl is correspondingly
15/// cfg-swapped between the default (`Send` futures) and `?Send` (no `Send`
16/// bound) variants.
17#[cfg(not(target_arch = "wasm32"))]
18pub trait NodeDbMarker: Send + Sync {}
19#[cfg(not(target_arch = "wasm32"))]
20impl<T: Send + Sync + ?Sized> NodeDbMarker for T {}
21
22#[cfg(target_arch = "wasm32")]
23pub trait NodeDbMarker {}
24#[cfg(target_arch = "wasm32")]
25impl<T: ?Sized> NodeDbMarker for T {}