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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
//! The [openvino] crate provides high-level, ergonomic, safe Rust bindings to OpenVINO. See the
//! repository [README] for more information, such as build instructions.
//!
//! [openvino]: https://crates.io/crates/openvino
//! [README]: https://github.com/intel/openvino-rs
//!
//! Check the loaded version of OpenVINO:
//! ```
//! assert!(openvino::version().starts_with("2"))
//! ```
//!
//! Most interaction with OpenVINO begins with instantiating a [Core]:
//! ```
//! let _ = openvino::Core::new(None).expect("to instantiate the OpenVINO library");
//! ```
#![deny(missing_docs)]
#![deny(clippy::all)]
#![warn(clippy::pedantic)]
#![warn(clippy::cargo)]
#![allow(
clippy::must_use_candidate,
clippy::module_name_repetitions,
clippy::missing_errors_doc,
clippy::len_without_is_empty
)]
mod blob;
mod core;
mod error;
mod network;
mod request;
mod tensor_desc;
mod util;
pub use crate::core::Core;
pub use blob::Blob;
pub use error::{InferenceError, LoadingError, SetupError};
pub use network::{CNNNetwork, ExecutableNetwork};
// Re-publish some OpenVINO enums with a conventional Rust naming (see
// `crates/openvino-sys/build.rs`).
pub use openvino_sys::{
layout_e as Layout, precision_e as Precision, resize_alg_e as ResizeAlgorithm,
};
pub use request::InferRequest;
pub use tensor_desc::TensorDesc;
/// Emit the version string of the OpenVINO C API backing this implementation.
///
/// # Panics
///
/// Panics if no OpenVINO library can be found.
pub fn version() -> String {
use std::ffi::CStr;
openvino_sys::load().expect("to have an OpenVINO shared library available");
let mut ie_version = unsafe { openvino_sys::ie_c_api_version() };
let str_version = unsafe { CStr::from_ptr(ie_version.api_version) }
.to_string_lossy()
.into_owned();
unsafe { openvino_sys::ie_version_free(std::ptr::addr_of_mut!(ie_version)) };
str_version
}