Skip to main content

rs_matter_utils/
sync.rs

1/*
2 *
3 *    Copyright (c) 2024-2026 Project CHIP Authors
4 *
5 *    Licensed under the Apache License, Version 2.0 (the "License");
6 *    you may not use this file except in compliance with the License.
7 *    You may obtain a copy of the License at
8 *
9 *        http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *    Unless required by applicable law or agreed to in writing, software
12 *    distributed under the License is distributed on an "AS IS" BASIS,
13 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *    See the License for the specific language governing permissions and
15 *    limitations under the License.
16 */
17
18pub use mutex::*;
19pub use notification::*;
20pub use signal::*;
21
22pub mod blocking;
23
24mod mutex;
25mod notification;
26mod signal;
27
28/// A bound on the types that `rs-matter` shares between its futures. Most `rs-matter` traits
29/// extend it.
30///
31/// With feature `send-sync`, this trait extends `Send + Sync`, so that these types can be shared
32/// between the threads of a work-stealing executor, and it is implemented for every type that is
33/// `Send + Sync`.
34#[cfg(feature = "send-sync")]
35pub trait MaybeSendSync: Send + Sync {}
36
37#[cfg(feature = "send-sync")]
38impl<T: ?Sized + Send + Sync> MaybeSendSync for T {}
39
40/// A bound on the types that `rs-matter` shares between its futures. Most `rs-matter` traits
41/// extend it.
42///
43/// Without feature `send-sync`, this trait is empty and implemented for every type.
44#[cfg(not(feature = "send-sync"))]
45pub trait MaybeSendSync {}
46
47#[cfg(not(feature = "send-sync"))]
48impl<T: ?Sized> MaybeSendSync for T {}
49
50/// A bound on the futures returned by `rs-matter` traits.
51///
52/// With feature `send-sync`, this trait extends `Send`, so that the futures can run on a
53/// work-stealing executor, and it is implemented for every type that is `Send`.
54#[cfg(feature = "send-sync")]
55pub trait MaybeSend: Send {}
56
57#[cfg(feature = "send-sync")]
58impl<T: ?Sized + Send> MaybeSend for T {}
59
60/// A bound on the futures returned by `rs-matter` traits.
61///
62/// Without feature `send-sync`, this trait is empty and implemented for every type.
63#[cfg(not(feature = "send-sync"))]
64pub trait MaybeSend {}
65
66#[cfg(not(feature = "send-sync"))]
67impl<T: ?Sized> MaybeSend for T {}