ixa::web_api

Trait ContextWebApiExt

Source
pub trait ContextWebApiExt {
    // Required methods
    fn setup_web_api(&mut self, port: u16) -> Result<String, IxaError>;
    fn schedule_web_api(&mut self, t: f64);
    fn add_web_api_handler(
        &mut self,
        name: &str,
        handler: impl Fn(&mut Context, Value) -> Result<Value, IxaError> + 'static,
    ) -> Result<(), IxaError>;
}

Required Methods§

Source

fn setup_web_api(&mut self, port: u16) -> Result<String, IxaError>

Set up the Web API and start the Web server.

§Errors

IxaError on failure to bind to port

Source

fn schedule_web_api(&mut self, t: f64)

Schedule the simulation to pause at time t and listen for requests from the Web API.

Source

fn add_web_api_handler( &mut self, name: &str, handler: impl Fn(&mut Context, Value) -> Result<Value, IxaError> + 'static, ) -> Result<(), IxaError>

Add an API point.

§Errors

IxaError when the Web API has not been set up yet.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§