pub struct Data<T: ?Sized>(/* private fields */);Expand description
Arc-wrapped shared data for use in contexts.
Data<T> wraps a value in an Arc for cheap cloning and sharing
across async tasks. It implements Deref for transparent access.
§Example
ⓘ
use evento::context::Data;
struct AppConfig {
database_url: String,
}
let config = Data::new(AppConfig {
database_url: "postgres://...".into(),
});
// Clone is cheap (just Arc clone)
let config2 = config.clone();
// Access inner value via Deref
println!("{}", config.database_url);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Data<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Data<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Data<T>
impl<T> Sync for Data<T>
impl<T> Unpin for Data<T>where
T: ?Sized,
impl<T> UnwindSafe for Data<T>where
T: RefUnwindSafe + ?Sized,
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