Skip to content

Sketch of public API #1

@fitzgen

Description

@fitzgen
impl Config {
    /// Enable or disable recording.
    pub fn recording(&mut self, enable: bool) -> &mut Self {
        todo!()
    }
}

impl Store {
    /// Initialize recording for this store.
    ///
    /// This store must not have been used to execute or instantiate any Wasm
    /// yet. This method returns an error if it has been.
    pub fn init_recording(&mut self, recorder: impl TraceWriter) -> Result<()> {
        ensure!(
            self.is_empty(),
            "cannot start recording after having executed Wasm"
        );

        todo!()
    }

    pub(crate) fn init_replaying(&mut self, replay: &Replay) -> Result<()> {
        assert!(
            self.is_empty(),
            "cannot start replaying after having executed Wasm"
        );
        todo!()
    }
}

// `Trace` is to `Replay` as `Module` is to `Instance`.
pub struct Trace {
    engine: Engine,

    // this needs to be `Clone` so we can make multiple replays from the same
    // trace
    reader: Box<dyn TraceReader>,
}

impl Trace {
    pub fn from_file(engine: &Engine, path: AsRef<Path>) -> Result<Self> {
        todo!()
    }

    pub fn from_reader(engine: &Engine, reader: impl TraceReader) -> Result<Self> {
        todo!()
    }

    pub fn add_module(&mut self, module: &Module) {
        todo!()
    }

    pub fn add_component(&mut self, component: &Component) {
        todo!()
    }

    pub fn instantiate(&self) -> Result<Replay> {
        // Allocate a new store, call our private `store.init_replaying()` API
        // to set the trace for replaying on the store, clone `self.reader` into
        // the resulting replay's store.
        todo!()
    }
}

pub struct Replay {
    // NB: `self.store` is not exposed so that embedders cannot call exported
    // functions that were not called in the trace.
    store: Store,
}

impl Replay {
    pub fn run(self) -> Result<()> {
        // Run the trace in this replay's specially-configured-for-replay store.
        todo!()
    }

    pub fn checkpoint(&mut self) -> Result<Checkpoint> {
        todo!()
    }

    pub fn go_to_checkpoint(&mut self, checkpoint: &Checkpoint) -> Result<()> {
        todo!()
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions