Skip to main content

thorvg_sys/
lib.rs

1//! Raw FFI bindings to the [ThorVG](https://github.com/thorvg/thorvg) vector graphics library.
2//!
3//! This crate provides unsafe, low-level bindings generated by `bindgen` from the ThorVG C API
4//! (`thorvg_capi.h`). For a safe, idiomatic Rust API, use the [`thorvg`] crate instead.
5//!
6//! This crate is `no_std` compatible.
7
8#![no_std]
9#![allow(non_upper_case_globals)]
10#![allow(non_camel_case_types)]
11#![allow(non_snake_case)]
12// Generated bindgen docs contain C-style identifiers
13#![allow(clippy::doc_markdown)]
14
15include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
16
17#[cfg(test)]
18mod tests {
19    extern crate std;
20
21    use super::*;
22
23    #[test]
24    fn test_engine_init_and_term() {
25        unsafe {
26            let result = tvg_engine_init(0);
27            assert_eq!(result, Tvg_Result::TVG_RESULT_SUCCESS);
28
29            let result = tvg_engine_term();
30            assert_eq!(result, Tvg_Result::TVG_RESULT_SUCCESS);
31        }
32    }
33
34    #[test]
35    fn test_engine_version() {
36        unsafe {
37            let mut major: u32 = 0;
38            let mut minor: u32 = 0;
39            let mut micro: u32 = 0;
40            let mut version: *const core::ffi::c_char = core::ptr::null();
41
42            let result = tvg_engine_version(
43                &raw mut major,
44                &raw mut minor,
45                &raw mut micro,
46                &raw mut version,
47            );
48            assert_eq!(result, Tvg_Result::TVG_RESULT_SUCCESS);
49            assert!(major >= 1);
50        }
51    }
52}