Skip to main content

Debugger

Struct Debugger 

Source
pub struct Debugger<T: Send + 'static> { /* private fields */ }
Expand description

A Debugger wraps up state associated with debugging the code running in a single Store.

It acts as a Future combinator, wrapping an inner async body that performs some actions on a store. Those actions are subject to the debugger, and debugger events will be raised as appropriate. From the “outside” of this combinator, it is always in one of two states: running or paused. When paused, it acts as a StoreContextMut and can allow examining the paused execution’s state. One runs until the next event suspends execution by invoking Debugger::run.

Implementations§

Source§

impl<T: Send + 'static> Debugger<T>

Source

pub fn new<F, I>(store: Store<T>, inner: F) -> Debugger<T>
where I: Future<Output = Result<Store<T>>> + Send + 'static, F: for<'a> FnOnce(Store<T>) -> I + Send + 'static,

Create a new Debugger that attaches to the given Store and runs the given inner body.

The debugger is always in one of two states: running or paused.

When paused, the holder of this object can invoke Debugger::run to enter the running state. The inner body will run until paused by a debug event. While running, the future returned by either of these methods owns the Debugger and hence no other methods can be invoked.

When paused, the holder of this object can access the Store indirectly by providing a closure

Source

pub fn is_complete(&self) -> bool

Is the inner body done running?

Source

pub async fn run(&mut self) -> Result<DebugRunResult>

Run the inner body until the next debug event.

This method is cancel-safe, and no events will be lost.

Source

pub async fn finish(&mut self) -> Result<()>

Run the debugger body until completion, with no further events.

Source

pub async fn with_store<F: FnOnce(StoreContextMut<'_, T>) -> R + Send + 'static, R: Send + 'static>( &mut self, f: F, ) -> Result<R>

Perform some action on the contained Store while not running.

This may only be invoked before the inner body finishes and when it is paused; that is, when the Debugger is initially created and after any call to run() returns a result other than DebugRunResult::Finished. If an earlier run() invocation was canceled, it must be re-invoked and return successfully before a query is made.

This is cancel-safe; if canceled, the result of the query will be dropped.

Source

pub async fn take_store(&mut self) -> Result<Option<Store<T>>>

Drop the Debugger once complete, returning the inner Store around which it was wrapped.

Only valid to invoke once run() returns DebugRunResult::Finished or after calling finish() (which finishes execution while dropping all further debug events).

This is cancel-safe, but if canceled, the Store is lost.

Auto Trait Implementations§

§

impl<T> Freeze for Debugger<T>

§

impl<T> RefUnwindSafe for Debugger<T>

§

impl<T> Send for Debugger<T>

§

impl<T> Sync for Debugger<T>

§

impl<T> Unpin for Debugger<T>

§

impl<T> UnwindSafe for Debugger<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.