relay_cabi/lib.rs
1//! This package contains the C-ABI of Relay. It builds a C header file and
2//! associated library that can be linked to any C or C++ program. Note that the
3//! header is C only. Primarily, this package is meant to be consumed by
4//! higher-level wrappers in other languages, such as the
5//! [`sentry-relay`](https://pypi.org/project/sentry-relay/) Python package.
6//!
7//! # Building
8//!
9//! Building the dynamic library has the same requirements as building the
10//! `relay` crate:
11//!
12//! - Latest stable Rust and Cargo
13//! - A checkout of this repository and all its GIT submodules
14//!
15//! To build, run `make release` in this directory. This creates a release build of
16//! the dynamic library in `target/release/librelay_cabi.*`.
17//!
18//! # Usage
19//!
20//! The header comes packaged in the `include/` directory. It does not have any
21//! dependencies other than standard C headers. Then, include it in sources and use
22//! like this:
23//!
24//! ```c
25//! #include "relay.h"
26//!
27//! int main() {
28//! RelayUuid uuid = relay_generate_relay_id();
29//! // use uuid
30//!
31//! return 0;
32//! }
33//! ```
34//!
35//! In your application, point to the Relay include directory and specify the
36//! `relay` library:
37//!
38//! ```bash
39//! $(CC) -Irelay-cabi/include -Ltarget/release -lrelay -o myprogram main.c
40//! ```
41//!
42//! # Development
43//!
44//! ## Requirements
45//!
46//! In addition to the build requirements, development requires a recent version
47//! of the the `cbindgen` tool. To set this up, run:
48//!
49//! ```bash
50//! cargo install cbindgen
51//! ```
52//!
53//! If your machine already has `cbindgen` installed, check the header of
54//! [`include/relay.h`] for the minimum version required. This can be verified by
55//! running `cbindgen --version`. It is generally advisable to keep `cbindgen`
56//! updated to its latest version, and always check in cbindgen updates separate
57//! from changes to the public interface.
58//!
59//! ## Makefile
60//!
61//! This package contains the Rust crate `relay-cabi` that exposes a public FFI
62//! interface. There are additional build steps involved in generating the header
63//! file located at `include/relay.h`. To aid development, there is a _Makefile_
64//! that exposes all relevant commands for building:
65//!
66//! - `make build`: Builds the library using `cargo`.
67//! - `make header`: Updates the header file based on the public interface.
68//! - `make clean`: Removes all build artifacts but leaves the header.
69//! - `make`: Builds the library and the header.
70//!
71//! For ease of development, the header is always checked into the repository. After
72//! making changes, do not forget to run at least `make header` to ensure the header
73//! is in sync with the library.
74//!
75//! ## Development Flow
76//!
77//! 1. Make changes to the `relay` crates and add tests.
78//! 2. Update `relay-cabi` and add, remove or update functions as needed.
79//! 3. Regenerate the header by running `make header` in the `relay-cabi/` directory.
80//! 4. Go to the Python package in the `py/` folder and update the high-level wrappers.
81//! 5. Consider whether this changeset requires a major version bump.
82//!
83//! The general rule for major versions is:
84//!
85//! - If everything is backward compatible, do **not major** bump.
86//! - If the C interface breaks compatibility but high-level wrappers are still
87//! backwards compatible, do **not major** bump. The C interface is currently
88//! viewed as an implementation detail.
89//! - If high-level wrappers are no longer backwards compatible or there are
90//! breaking changes in the `relay` crate itself, **do major** bump.
91
92#![allow(clippy::missing_safety_doc)]
93#![warn(missing_docs)]
94#![doc(
95 html_logo_url = "https://raw.githubusercontent.com/getsentry/relay/master/artwork/relay-icon.png",
96 html_favicon_url = "https://raw.githubusercontent.com/getsentry/relay/master/artwork/relay-icon.png"
97)]
98#![allow(clippy::derive_partial_eq_without_eq)]
99
100mod auth;
101mod codeowners;
102mod constants;
103mod core;
104mod ffi;
105mod glob;
106mod processing;
107
108pub use crate::auth::*;
109pub use crate::codeowners::*;
110pub use crate::constants::*;
111pub use crate::core::*;
112pub use crate::ffi::*;
113pub use crate::glob::*;
114pub use crate::processing::*;