#trackable

trackable

This library provides a way to track objects manually as an alternative to mechanisms like backtracing

34 releases (1 stable)

Uses old Rust 2015

1.0.0 May 5, 2020
0.2.23 Aug 18, 2019
0.2.22 May 12, 2019
0.2.21 Jan 21, 2019
0.1.6 Mar 22, 2017

#135 in Debugging

Download history 2601/week @ 2020-04-13 2713/week @ 2020-04-20 2839/week @ 2020-04-27 2476/week @ 2020-05-04 3393/week @ 2020-05-11 2445/week @ 2020-05-18 3131/week @ 2020-05-25 2632/week @ 2020-06-01 2339/week @ 2020-06-08 2256/week @ 2020-06-15 2364/week @ 2020-06-22 2329/week @ 2020-06-29 3136/week @ 2020-07-06 3032/week @ 2020-07-13 3415/week @ 2020-07-20 3309/week @ 2020-07-27

9,013 downloads per month
Used in less than 60 crates

MIT license

47KB
784 lines

trackable

Crates.io: trackable Documentation Build Status Code Coverage License: MIT

trackable provides functionalities to define trackable objects and track those.

Documentation

Below code is an example that tracks failure of an I/O operation:

#[macro_use]
extern crate trackable;

use trackable::error::Failure;

fn foo() -> Result<(), Failure> {
    track!(std::fs::File::open("/path/to/non_existent_file").map_err(Failure::from_error))?;
    Ok(())
}
fn bar() -> Result<(), Failure> {
    track!(foo())?;
    Ok(())
}
fn baz() -> Result<(), Failure> {
    track!(bar())?;
    Ok(())
}

fn main() {
    let result = baz();
    assert!(result.is_err());

    let error = result.err().unwrap();
    assert_eq!(format!("\r{}", error), r#"
Failed (cause; No such file or directory)
HISTORY:
  [0] at rust_out:<anon>:7
  [1] at rust_out:<anon>:12
  [2] at rust_out:<anon>:16
"#);
}

This example used the built-in Failure type, but you can easily define your own trackable error types. See the documentaion of error module for more details.

Dependencies

~375–780KB
~19K SLoC