Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
.github/ | H | 03-May-2022 | - | 130 | 110 | |
examples/ | H | 03-May-2022 | - | 32 | 27 | |
src/ | H | 03-May-2022 | - | 1,523 | 801 | |
.cargo-checksum.json | H A D | 03-May-2022 | 89 | 1 | 1 | |
.cargo_vcs_info.json | H A D | 01-Jan-1970 | 74 | 6 | 5 | |
.gitignore | H A D | 01-Jan-1970 | 18 | 3 | 2 | |
Cargo.lock | H A D | 01-Jan-1970 | 2.7 KiB | 108 | 96 | |
Cargo.toml | H A D | 01-Jan-1970 | 1.1 KiB | 39 | 34 | |
Cargo.toml.orig-cargo | H A D | 01-Jan-1970 | 630 | 24 | 19 | |
LICENSE | H A D | 01-Jan-1970 | 1.1 KiB | 22 | 17 | |
README.md | H A D | 01-Jan-1970 | 1.6 KiB | 52 | 41 |
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