Interact is a framework for friendly online introspection of the running program state in an intuitive command-line interactive way.
You may be looking for:
Interact is useful for server programs that otherwise receive no input. You can use Interact to make your server receive commands using the special prompt from the interact_prompt crate. The commands can be used to browse your server's internal state, modify it, and call methods that were specified in interact derive attributes.
Interact is implemented for stable Rust, using only safe mode.
While dynamically-typed interpreted languages offer the advantage of being able to look at a running program state using a prompt, compiled languages often do not provide that feature. Being hard as it is to introduce interpreters into compiled languages, the Interact project aims to provide a midway solution using stable Rust.
#[derive(Interact)].
#[interact(skip)] for problematic fields.Rc, RefCell, Arc, or Mutex, even with reference loops. Handling for that exists, as demonstrated later.interact_prompt's registry.interact_prompt either directly or in its own OS thread (async not supported yet).node.some_map["value"].field.sub_field.= <value>.interact attributes.Rc or otherwise) are handled gracefully in reflected values - a unique number is printed at all the common sites: the first encounter and the repeats.Addr<T> can be traversed into, exposing the full server state (see the example in the book).The program below registers states and invokes the Interact prompt on the main thread.
extern crate interact;
use interact::Interact;
use interact_prompt::{LocalRegistry, Settings};
use std::{cell::RefCell, rc::Rc};
#[derive(Interact)]
struct Point {
x: i32,
y: i32,
}
#[derive(Interact)]
struct State {
maybe_point: Option<Point>,
complex: ((((usize, usize), u32, (u32, (u32,))), u32), u32),
behind_rc: Rc<RefCell<u32>>,
behind_rc2: Rc<RefCell<u32>>,
}
fn main() -> Result<(), interact_prompt::PromptError> {
let rc = Rc::new(RefCell::new(3));
let state = State {
maybe_point: Some(Point { x: 3, y: 3 }),
complex: ((((0, 0), 0, (0, (0,))), 0), 0),
behind_rc: rc.clone(),
behind_rc2: rc,
};
LocalRegistry::insert("state", Box::new(state));
interact_prompt::direct(Settings::default(), ())?;
Ok(())
}
(this is just one mode for using the Interact prompt. Another mode is running it in the background allowing it to traverse, access, and modify the global process state safely and without interference).
When cloning this repository, it can be run using cargo run --example mini-example. Here's a recorded session:
You are more than welcome to browse and open new issues!
Interact is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Interact by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.
Rust
100.0%
Interact is a framework for friendly online introspection of the running program state in an intuitive command-line interactive way.
You may be looking for:
Interact is useful for server programs that otherwise receive no input. You can use Interact to make your server receive commands using the special prompt from the interact_prompt crate. The commands can be used to browse your server's internal state, modify it, and call methods that were specified in interact derive attributes.
Interact is implemented for stable Rust, using only safe mode.
While dynamically-typed interpreted languages offer the advantage of being able to look at a running program state using a prompt, compiled languages often do not provide that feature. Being hard as it is to introduce interpreters into compiled languages, the Interact project aims to provide a midway solution using stable Rust.
#[derive(Interact)].
#[interact(skip)] for problematic fields.Rc, RefCell, Arc, or Mutex, even with reference loops. Handling for that exists, as demonstrated later.interact_prompt's registry.interact_prompt either directly or in its own OS thread (async not supported yet).node.some_map["value"].field.sub_field.= <value>.interact attributes.Rc or otherwise) are handled gracefully in reflected values - a unique number is printed at all the common sites: the first encounter and the repeats.Addr<T> can be traversed into, exposing the full server state (see the example in the book).The program below registers states and invokes the Interact prompt on the main thread.
extern crate interact;
use interact::Interact;
use interact_prompt::{LocalRegistry, Settings};
use std::{cell::RefCell, rc::Rc};
#[derive(Interact)]
struct Point {
x: i32,
y: i32,
}
#[derive(Interact)]
struct State {
maybe_point: Option<Point>,
complex: ((((usize, usize), u32, (u32, (u32,))), u32), u32),
behind_rc: Rc<RefCell<u32>>,
behind_rc2: Rc<RefCell<u32>>,
}
fn main() -> Result<(), interact_prompt::PromptError> {
let rc = Rc::new(RefCell::new(3));
let state = State {
maybe_point: Some(Point { x: 3, y: 3 }),
complex: ((((0, 0), 0, (0, (0,))), 0), 0),
behind_rc: rc.clone(),
behind_rc2: rc,
};
LocalRegistry::insert("state", Box::new(state));
interact_prompt::direct(Settings::default(), ())?;
Ok(())
}
(this is just one mode for using the Interact prompt. Another mode is running it in the background allowing it to traverse, access, and modify the global process state safely and without interference).
When cloning this repository, it can be run using cargo run --example mini-example. Here's a recorded session:
You are more than welcome to browse and open new issues!
Interact is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Interact by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.
Rust
100.0%