pub trait ObjectMarkerFor<T>:
Sealed
+ Sized
+ 'static { }Expand description
Marker trait combining object and thread-safety requirements.
This trait enforces thread-safety constraints for context and attachment data at report construction time. Reports can only be constructed when their context and attachments satisfy the requirements of the thread-safety marker.
§Implementations
-
For
T = Local: Implemented for allSized + 'statictypes, regardless of theirSend/Syncstatus. This allows using types likeRcin local reports. -
For
T = SendSync: Implemented only forSized + 'statictypes that are alsoSend + Sync. This ensures thread-safe reports can only be constructed with thread-safe data.
§Enforcement at Construction
The key insight is that this trait is used as a bound during report
construction. You cannot create a Report<C, _, SendSync> unless C: ObjectMarkerFor<SendSync>, which requires C: Send + Sync. This makes it
impossible to accidentally create an invalid report:
use std::rc::Rc;
use rootcause::prelude::*;
// This won't compile because Rc is not Send + Sync
let rc_data: Rc<String> = Rc::new("error".to_string());
let report: Report<Rc<String>, markers::Mutable, markers::SendSync> = report!(rc_data);Use Local instead for non-thread-safe data:
use std::rc::Rc;
use rootcause::prelude::*;
let rc_data: Rc<String> = Rc::new("error".to_string());
let report: Report<Rc<String>, markers::Mutable, markers::Local> = report!(rc_data);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.