logo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! Resource management

pub use warmy::{Res, Store, StoreOpt};

pub mod error;

mod key;
pub use self::key::*;

// /// Load helper.
// ///
// /// Call this fn whenever you need to load a resource and that you want logged information,
// /// such as failures, timing, etc.
// pub fn load_with<T, A, E, F>(
//   path: &Path,
//   loader: F
// ) -> Result<A, E>
// where F: FnOnce() -> Result<A, E>,
//       T: TyDesc {
//   info!("loading {} {}", T::TY_DESC, path.display());
//
//   let start_time = Instant::now();
//   let r = loader();
//   let t = start_time.elapsed();
//   let ns = t.as_secs() as f64 * 1e9 + t.subsec_nanos() as f64;
//   let (pretty_time, suffix) = load_time(ns);
//
//   if let Ok(_) = r {
//     info!("loaded {} {}: {:.3}{}", T::TY_DESC, path.display(), pretty_time, suffix);
//   } else {
//     err!("fail to load {} {}: {:.3}{}", T::TY_DESC, path.display(), pretty_time, suffix);
//   }
//
//   r
// }