interact-rs / interact Goto Github PK
View Code? Open in Web Editor NEWOnline introspection for Rust
License: Apache License 2.0
Online introspection for Rust
License: Apache License 2.0
Type state..
into the example it will always panic after typing the second period:
# RUST_BACKTRACE=1 ./target/debug/examples/mini-example
Rust `interact`, type '?' for more information
>>> state..
->
e# RUST_BACKTRACE=1 ./target/debug/examples/mini-example
Rust `interact`, type '?' for more information
>>> state.thread 'main' panicked at 'byte index 2 is out of bounds of `.`', src/libcore/str/mod.rs:2196:9
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1063
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1426
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:204
9: std::panicking::default_hook
at src/libstd/panicking.rs:224
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:470
11: rust_begin_unwind
at src/libstd/panicking.rs:378
12: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
13: core::str::slice_error_fail
at src/libcore/str/mod.rs:0
14: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeFrom<usize>>::index::{{closure}}
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/str/mod.rs:2051
15: core::option::Option<T>::unwrap_or_else
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/option.rs:428
16: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeFrom<usize>>::index
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/str/mod.rs:2051
17: core::str::traits::<impl core::ops::index::Index<I> for str>::index
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/str/mod.rs:1780
18: <alloc::string::String as core::ops::index::Index<core::ops::range::RangeFrom<usize>>>::index
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/liballoc/string.rs:2017
19: <interact_prompt::InteractPromptHelper<H> as rustyline::hint::Hinter>::hint
at ./interact_prompt/src/lib.rs:343
20: rustyline::edit::State<H>::hint
at /home/at/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-6.1.2/src/edit.rs:175
21: rustyline::edit::State<H>::edit_insert
at /home/at/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-6.1.2/src/edit.rs:310
22: rustyline::readline_edit
at /home/at/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-6.1.2/src/lib.rs:468
23: rustyline::readline_raw
at /home/at/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-6.1.2/src/lib.rs:697
24: rustyline::Editor<H>::readline_with
at /home/at/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-6.1.2/src/lib.rs:826
25: rustyline::Editor<H>::readline
at /home/at/.cargo/registry/src/github.com-1ecc6299db9ec823/rustyline-6.1.2/src/lib.rs:802
26: interact_prompt::direct
at ./interact_prompt/src/lib.rs:440
27: mini_example::main
at interact_prompt/examples/mini-example.rs:31
28: std::rt::lang_start::{{closure}}
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/rt.rs:67
29: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:52
30: std::panicking::try::do_call
at src/libstd/panicking.rs:303
31: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:86
32: std::panicking::try
at src/libstd/panicking.rs:281
33: std::panic::catch_unwind
at src/libstd/panic.rs:394
34: std::rt::lang_start_internal
at src/libstd/rt.rs:51
35: std::rt::lang_start
at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/rt.rs:67
36: main
37: __libc_start_main
38: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
I see the same thing with the old rustyline, so I don't think I caused this in #15.
This happens when typing a large number (I did not press Enter):
# cargo run --example mini-example
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `target/debug/examples/mini-example`
Rust `interact`, type '?' for more information
>>> state.complex.0.0.0.0 = 10000000000000000000thread 'main' panicked at 'IntError(ParseIntError { kind: Overflow })', interact/src/root.rs:123:67
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
NOTE: Unless you are manually extending types for use under Interact, you probably don't need most of the items that are exported in this crate. Instead, look for the interact_prompt crate.
So maybe https://docs.rs/interact_prompt should be listed before https://docs.rs/interact/?
In large-example
, for instance complex.refs.arc_b.field_b = 3
, the UnexpectedToken
error is not very helpful.
My type has this set of attributes
#[derive(Derivative)] // from `derivative` crate.
#[derivative(Debug)]
#[cfg_attr(feature = "interact", derive(Interact)]
Result:
error: proc-macro derive panicked
--> factory/src/factory.rs:80:41
|
80 | #[cfg_attr(feature = "interact", derive(Interact))]
| ^^^^^^^^^^^^^^^^^^
|
= help: message: Invalid term Debug in `( Debug )`
Reflector having issues with 0-sized values such as ()
, thinking it has already seen them. May need to find a way to use std::mem::size_of
to keep from introducing them into the hashset of addresses during reflection.
This could be useful in a wide range of applications, if it had the capability to act in a client / server manner.
For example, GTK provides a useful tool for debugging and manipulating GTK widget properties in any GTK application externally with the GTK Inspector. A similar capability could be offered by this and OrbTk.
Varlink could be used as a protocol for communicating messages back and forth between a pipe, UNIX socket, TCP socket, scheme, etc.
interact_prompt uses a quite outdated rustyline (2.1) It seems as it is not compiling with nightly any more.
I don't know if it is a rustc issue or some experimental feature gated thing, but could you please update it to the latest version (Actually your version is behind to latest by 2 major version)
Currently, the reflector in Interact limits the amount of data gathered for each entered expression in interact_prompt
. This serves to prevent terminal overflow when trying to print large amount of data, for example if the registered state is very large. However, in order to allow easy probing of very large maps, we would need more flexibility.
BTreeMap
), it would be nice to provide ranges. For hashmaps, we can provide how much of the iterator's items we would like to skip.I've tried to override and create a custom handler to stop the input thread, but It is not called unless there is a console input (Enter).
It'd be great if the direct version can be stopped from another thread.
Something like this:
struct InteractHandler {
stop_signal: Weak<()>,
}
impl interact_prompt::Handler for InteractHandler {
fn receive_interaction(&self, intr: interact_prompt::Interaction) -> interact_prompt::Response {
log::info!("called only on console input, newline?");
if self.stop_signal.upgrade().is_none() {
interact_prompt::Response::Exit
} else {
match intr {
/*interact_prompt::Interaction::Line(string) => {
Commands::new().handle_cmd(&string);
}*/
_ => {}
}
interact_prompt::Response::Continue
}
}
}
Error message:
#[cfg_attr(feature = "interact", derive(Interact))]
| ^^^^^^^^
|
= help: message: extend () in `interact` data type attribute `Literal { lit: Str_( Memory utilization stats.), suffix: None, span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 } }`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.