pub struct Local;Expand description
Marker type indicating that a report is not Send or Sync.
This marker is used when a report contains thread-local data that cannot be
safely sent between threads or shared across threads. Common examples
include Rc, raw pointers, or types that explicitly opt out of
Send/Sync.
§When to Use
Use Local when your error context or attachments contain:
Rc<T>orWeak<T>(useArc<T>for thread-safe alternative)- Raw pointers (
*const T,*mut T) - Types that wrap thread-local storage
- Any type that is
!Sendor!Sync
§Converting to Local
You can convert a thread-safe report to a local one using
into_local, or create a local report directly
when the context type is not Send + Sync.
§Examples
use std::rc::Rc;
use rootcause::prelude::*;
// Rc is not Send or Sync, so the report must be Local
let local_data: Rc<String> = Rc::new("Thread-local error".to_string());
let report: Report<Rc<String>, markers::Mutable, markers::Local> = report!(local_data);
// This report cannot be sent to another thread
// std::thread::spawn(move || {
// println!("{}", report); // ❌ Won't compile
// });Converting a thread-safe report to local:
use std::rc::Rc;
use rootcause::prelude::*;
let report: Report<String> = report!("Error".to_string());
// Convert to local report so we can use thread-local data
let local_report: Report<String, markers::Mutable, markers::Local> = report.into_local();Trait Implementations§
Source§impl<C, O, T> IntoReportCollection<Local> for Report<C, O, T>where
C: ?Sized,
O: ReportOwnershipMarker,
impl<C, O, T> IntoReportCollection<Local> for Report<C, O, T>where
C: ?Sized,
O: ReportOwnershipMarker,
Source§fn into_report_collection(self) -> ReportCollection<Self::Context, Local>
fn into_report_collection(self) -> ReportCollection<Self::Context, Local>
Source§impl<C, T> IntoReportCollection<Local> for ReportCollection<C, T>where
C: ?Sized,
impl<C, T> IntoReportCollection<Local> for ReportCollection<C, T>where
C: ?Sized,
Source§fn into_report_collection(self) -> ReportCollection<Self::Context, Local>
fn into_report_collection(self) -> ReportCollection<Self::Context, Local>
Source§impl Ord for Local
impl Ord for Local
Source§impl PartialOrd for Local
impl PartialOrd for Local
impl Copy for Local
impl Eq for Local
impl StructuralPartialEq for Local
Auto Trait Implementations§
impl Freeze for Local
impl RefUnwindSafe for Local
impl Send for Local
impl Sync for Local
impl Unpin for Local
impl UnwindSafe for Local
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.