pub trait SharedHandle<T: 'static>: Clone + 'static {
// Required method
fn get(&self) -> &T;
}Expand description
Shared handle to a single owned-or-borrowed T.
One trait covering every “Server holds an Arc<T> for sharing
between its run loop and consumer-side tasks” pattern in this
crate. Replaces the three separate handle traits this crate
shipped earlier (SocketHandle, SdStateHandle,
EventPublisherHandle), each of which had the same shape with
a different concrete T.
Two impls ship out of the box, both via blanket impls so any
consumer-defined type wrapped in Arc<T> or &'static T
satisfies the bound automatically:
Arc<T>: SharedHandle<T>on alloc-using builds (stdorbare_metal-with-alloc).Arc::cloneincrements the refcount;getreturns the inner reference.&'static T: SharedHandle<T>on bare-metal-no-alloc. The reference isCopy + Clone + 'static; the user declares the underlyingstaticstorage at boot.
Clone + 'static only — neither Send nor Sync at the
trait level. Method-level where clauses on Server add
Send bounds at the use sites that need them
(announcement_loop’s + Send return type, etc.).
T: 'static because both blanket impls require it: an Arc<T>
is 'static only when T: 'static, and &'static T requires
T: 'static by definition.
?Sized is intentionally NOT supported — the inline-construction
path (WrappableSharedHandle::wrap) needs an owned T, which
requires Sized.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".