dlt_sys/lib.rs
1/*
2 * Copyright (c) 2025 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS)
3 *
4 * See the NOTICE file(s) distributed with this work for additional
5 * information regarding copyright ownership.
6 *
7 * This program and the accompanying materials are made available under the
8 * terms of the Apache License Version 2.0 which is available at
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 */
13
14//! Low-level FFI bindings to the COVESA DLT (Diagnostic Log and Trace) C library (`libdlt`).
15//!
16//! # Overview
17//!
18//! `dlt-sys` provides unsafe Rust bindings to the
19//! [COVESA DLT daemon](https://github.com/COVESA/dlt-daemon) C library.
20//! This crate is intended to be used as a foundation for higher-level safe
21//! Rust abstractions (see [`dlt-rs`](https://crates.io/crates/dlt-rs)).
22//!
23//! **Note:** This crate only implements functionality required for `dlt-rs` and does not cover
24//! the entire `libdlt` API.
25//!
26//! # Features
27//!
28//! - Direct FFI bindings to `libdlt` functions
29//! - Custom C wrapper for improved API ergonomics
30//! - Support for all DLT log levels and message types
31//! - Optional `trace_load_ctrl` feature for load control support
32//!
33//! # Prerequisites
34//!
35//! **libdlt** and its development headers must be installed on your system.
36//!
37//! # Usage
38//!
39//! This is a low-level crate with unsafe APIs. Most users should use
40//! [`dlt-rs`](https://crates.io/crates/dlt-rs) instead for a safe, idiomatic Rust API.
41//!
42//! # Cargo Features
43//!
44//! - `trace_load_ctrl` - Enable DLT load control support
45//! - `generate-bindings` - Regenerate bindings from C headers (development only)
46//!
47//! # Safety
48//!
49//! All functions in this crate are `unsafe` as they directly call C library functions.
50//! Proper usage requires understanding of:
51//! - DLT library initialization and cleanup
52//! - Memory management across FFI boundaries
53//! - Thread safety considerations
54//!
55//! For safe abstractions, use the [`dlt-rs`](https://crates.io/crates/dlt-rs) crate.
56//!
57//! # References
58//!
59//! - [COVESA DLT Daemon](https://github.com/COVESA/dlt-daemon)
60
61#[rustfmt::skip]
62#[allow(clippy::all,
63 dead_code,
64 warnings,
65 clippy::arithmetic_side_effects,
66 clippy::indexing_slicing,
67)]
68mod dlt_bindings {
69 include!(concat!(env!("OUT_DIR"), "/dlt_bindings.rs"));
70}
71
72pub use dlt_bindings::*;
73
74impl Default for DltContextData {
75 fn default() -> Self {
76 // DltContextData fields differ between libdlt releases.
77 // Zero-initialization keeps this crate source-compatible across versions.
78 unsafe { std::mem::zeroed() }
79 }
80}