async_tensorrt/ffi/mod.rs
1// The order of these includes is important due to the nature of how the `cpp` crate works. We want
2// the C++ includes, helpers and other global stuff to be initialized in order or it might not
3// compile correctly.
4#[rustfmt::skip]
5mod pre {
6 mod includes;
7 mod shims;
8 mod helpers;
9 mod logger;
10}
11
12pub mod builder_config;
13pub mod error;
14pub mod memory;
15pub mod network;
16pub mod optimization_profile;
17pub mod parser;
18pub mod sync;
19pub mod version;
20
21/// Convenience macro for turning TensorRT error code into a `std::result::Result`.
22///
23/// # Usage
24///
25/// There are two possible uses of the macro:
26///
27/// (1) Shorthand to return `Ok(something)` or the most recent TensorRT error:
28///
29/// ```ignore
30/// result!(return_value);
31/// ```
32///
33/// (2) Shorthand to return `Ok(())` or the most recent TensorRT error:
34///
35/// ```ignore
36/// result!(code)
37/// ```
38macro_rules! result {
39 ($ptr:expr, $ok:expr) => {
40 if !$ptr.is_null() {
41 Ok($ok)
42 } else {
43 Err($crate::error::last_error())
44 }
45 };
46 ($ptr:expr) => {
47 result!($ptr, ())
48 };
49}
50
51use result;