Struct libafl_bolts::staterestore::StateRestorer
source · pub struct StateRestorer<SP>where
SP: ShMemProvider,{ /* private fields */ }
Expand description
A StateRestorer
saves and restores bytes to a shared map.
If the state gets larger than the preallocated ShMem
shared map,
it will instead write to disk, and store the file name into the map.
Writing to StateRestorer
multiple times is not allowed.
Implementations§
source§impl<SP> StateRestorer<SP>where
SP: ShMemProvider,
impl<SP> StateRestorer<SP>where
SP: ShMemProvider,
sourcepub fn mapsize(&self) -> usize
pub fn mapsize(&self) -> usize
Get the map size backing this StateRestorer
.
sourcepub fn write_to_env(&self, env_name: &str) -> Result<(), Error>
pub fn write_to_env(&self, env_name: &str) -> Result<(), Error>
Writes this StateRestorer
to env variable, to be restored later
sourcepub fn from_env(shmem_provider: &mut SP, env_name: &str) -> Result<Self, Error>
pub fn from_env(shmem_provider: &mut SP, env_name: &str) -> Result<Self, Error>
Create a StateRestorer
from env
variable name
sourcepub fn new(shmem: SP::ShMem) -> Self
pub fn new(shmem: SP::ShMem) -> Self
Create a new StateRestorer
.
sourcepub fn save<S>(&mut self, state: &S) -> Result<(), Error>where
S: Serialize,
pub fn save<S>(&mut self, state: &S) -> Result<(), Error>where
S: Serialize,
Saves a state to the connected ShMem
, or a tmpfile, if its serialized size get too large.
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset this StateRestorer
to an empty state.
sourcepub fn send_exiting(&mut self)
pub fn send_exiting(&mut self)
When called from a child, informs the restarter/parent process that it should no longer respawn the child.
sourcepub fn wants_to_exit(&self) -> bool
pub fn wants_to_exit(&self) -> bool
Returns true, if Self::send_exiting
was called on this StateRestorer
last.
This should be checked in the parent before deciding to restore the client.
sourcepub fn has_content(&self) -> bool
pub fn has_content(&self) -> bool
Returns true, if this StateRestorer
has contents.
sourcepub fn restore<S>(&self) -> Result<Option<S>, Error>where
S: DeserializeOwned,
pub fn restore<S>(&self) -> Result<Option<S>, Error>where
S: DeserializeOwned,
Restores the contents saved in this StateRestorer
, if any are available.
Can only be read once.
Trait Implementations§
source§impl<SP> Clone for StateRestorer<SP>
impl<SP> Clone for StateRestorer<SP>
source§fn clone(&self) -> StateRestorer<SP>
fn clone(&self) -> StateRestorer<SP>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<SP> RefUnwindSafe for StateRestorer<SP>
impl<SP> !Send for StateRestorer<SP>
impl<SP> !Sync for StateRestorer<SP>
impl<SP> Unpin for StateRestorer<SP>
impl<SP> UnwindSafe for StateRestorer<SP>
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
source§impl<Tail, T> Prepend<T> for Tail
impl<Tail, T> Prepend<T> for Tail
§type PreprendResult = Tail
type PreprendResult = Tail
TupleList
, of an Prepend::prepend()
call,
including the prepended entry.