pub struct Unwinder<'a> { /* private fields */ }
Expand description
Unwinds the stack of stored events to get the local data to a previous state.
Has nothing to do with unwinding of the program’s stack in a panic!
.
Implementations§
source§impl<'a> Unwinder<'a>
impl<'a> Unwinder<'a>
sourcepub fn sections<'b>(
&'b self,
modern_resource_name: &'b str
) -> Option<impl Iterator<Item = &Difference> + 'b>
pub fn sections<'b>( &'b self, modern_resource_name: &'b str ) -> Option<impl Iterator<Item = &Difference> + 'b>
Get an iterator over the Difference
s to modern_resource_name
.
Returns None
if modern_resource_name
was destroyed/created
during the events we’re tracking.
sourcepub fn events(&self) -> impl Iterator<Item = &Event> + DoubleEndedIterator + '_
pub fn events(&self) -> impl Iterator<Item = &Event> + DoubleEndedIterator + '_
Get an iterator over the events stored in this unwinder. The first item is the oldest one. The last is the most recent.
Useful it you want to get resources affected since a timestamp:
use std::time::{Duration, SystemTime};
let manager = Manager::new(false, 0, Duration::from_secs(60), 512);
let unwinder = manager.unwinder_to(SystemTime::now() - Duration::from_secs(2));
for event in unwinder.events() {
println!("Resource {} changed in some way.", event.resource());
}
sourcepub fn unwind(
&mut self,
resource: impl Into<Vec<u8>>,
modern_resource_name: &str
) -> Result<Vec<u8>, UnwindError>
pub fn unwind( &mut self, resource: impl Into<Vec<u8>>, modern_resource_name: &str ) -> Result<Vec<u8>, UnwindError>
Reverts the resource
with modern_resource_name
to the bottom of the internal list.
Panics
If you called this before and didn’t call Self::unwind
, this panics.
Errors
Returns UnwindError::ResourceDestroyed
if modern_resource_name
has been re-created or
destroyed during the timeline of this unwinder.