• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H03-May-2022-130110

examples/H03-May-2022-3227

src/H03-May-2022-1,523801

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.gitignoreH A D01-Jan-197018 32

Cargo.lockH A D01-Jan-19702.7 KiB10896

Cargo.tomlH A D01-Jan-19701.1 KiB3934

Cargo.toml.orig-cargoH A D01-Jan-1970630 2419

LICENSEH A D01-Jan-19701.1 KiB2217

README.mdH A D01-Jan-19701.6 KiB5241

README.md

1trackable
2=========
3
4[![Crates.io: trackable](https://img.shields.io/crates/v/trackable.svg)](https://crates.io/crates/trackable)
5[![Documentation](https://docs.rs/trackable/badge.svg)](https://docs.rs/trackable)
6[![Actions Status](https://github.com/sile/trackable/workflows/CI/badge.svg)](https://github.com/sile/trackable/actions)
7[![Coverage Status](https://coveralls.io/repos/github/sile/trackable/badge.svg?branch=master)](https://coveralls.io/github/sile/trackable?branch=master)
8[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
9
10`trackable` provides functionalities to define trackable objects and track those.
11
12[Documentation](https://docs.rs/trackable)
13
14Below code is an example that tracks failure of an I/O operation:
15
16```rust
17#[macro_use]
18extern crate trackable;
19
20use trackable::error::Failure;
21
22fn foo() -> Result<(), Failure> {
23    track!(std::fs::File::open("/path/to/non_existent_file").map_err(Failure::from_error))?;
24    Ok(())
25}
26fn bar() -> Result<(), Failure> {
27    track!(foo())?;
28    Ok(())
29}
30fn baz() -> Result<(), Failure> {
31    track!(bar())?;
32    Ok(())
33}
34
35fn main() {
36    let result = baz();
37    assert!(result.is_err());
38
39    let error = result.err().unwrap();
40    assert_eq!(format!("\r{}", error), r#"
41Failed (cause; No such file or directory)
42HISTORY:
43  [0] at rust_out:<anon>:7
44  [1] at rust_out:<anon>:12
45  [2] at rust_out:<anon>:16
46"#);
47}
48```
49
50This example used the built-in `Failure` type, but you can easily define your own trackable error types.
51See the documentaion of [error](https://docs.rs/trackable/0.2/trackable/error/index.html) module for more details.
52