rustolio_utils/threadsafe.rs
1//
2// SPDX-License-Identifier: MPL-2.0
3//
4// Copyright (c) 2026 Tobias Binnewies. All rights reserved.
5//
6// This Source Code Form is subject to the terms of the Mozilla Public
7// License, v. 2.0. If a copy of the MPL was not distributed with this
8// file, You can obtain one at http://mozilla.org/MPL/2.0/.
9//
10
11/// A trait for types that implement `Send` and `Sync` and are `'static`.
12/// This is just a 'wrapper' for these implementations.
13pub trait Threadsafe: Send + Sync + 'static {}
14impl<T> Threadsafe for T where T: Send + Sync + 'static {}
15
16// pub trait ThreadsafeStatic: Threadsafe + 'static {}
17// impl<T> ThreadsafeStatic for T where T: Threadsafe + 'static {}
18
19pub trait Future: std::future::Future<Output: Threadsafe> + Send + Sync {
20 // #[inline]
21 // fn poll(
22 // self: std::pin::Pin<&mut Self>,
23 // cx: &mut std::task::Context<'_>,
24 // ) -> std::task::Poll<Self::Output> {
25 // std::future::Future::poll(self, cx)
26 // }
27}
28impl<F> Future for F where F: std::future::Future<Output: Threadsafe> + Send + Sync {}
29
30pub trait Error: std::error::Error + Threadsafe {}
31impl<E> Error for E where E: std::error::Error + Threadsafe {}