pub struct EventData { /* private fields */ }Expand description
Data attached to an event, detached from the event.
Formats and values attach data to individual events (see
State::event), for instance tags or formatting
hints. This captures such data so that it can be attached to an event
again later. This is used by types which hold on to values outside of a
serialization or deserialization, such as the values of the
deser-value crate, so that data like CBOR tags survives.
use deser::de::DeserializeDriver;
use deser::EventData;
#[derive(Debug, Default, Clone, PartialEq)]
struct Tag(u64);
let mut data = EventData::new();
data.insert(Tag(42));
assert_eq!(data.get::<Tag>(), Some(&Tag(42)));
let mut out = None::<bool>;
let mut driver = DeserializeDriver::new(&mut out);
driver.state_mut().attach_event_data(&data);
assert_eq!(driver.state().event::<Tag>(), Some(&Tag(42)));
assert_eq!(
driver.state().capture_event_data().get::<Tag>(),
Some(&Tag(42))
);Event data has to be Send and Sync, which means that captured
event data is too.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EventData
impl !UnwindSafe for EventData
impl Freeze for EventData
impl Send for EventData
impl Sync for EventData
impl Unpin for EventData
impl UnsafeUnpin for EventData
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