3
3
Bindings to Zephyr for Rust
4
4
###########################
5
5
6
- Zephyr is written in C, and it's primary API is also made available to C. It is written as a
6
+ Zephyr is written in C, and its primary API is also made available to C. It is written as a
7
7
mixture of types, function prototypes, inline functions, and macros.
8
8
9
9
Although Rust interfaces fairly easily with C at an ABI level, the compiler does not have any
@@ -22,21 +22,21 @@ generate the Rust code needed to call this code.
22
22
23
23
Because the Zephyr headers use numerous conditional compilation macros, the bindings needed will be
24
24
very specialized to a given board, and even a given configuration. To do this, the file
25
- :file: `lib/rust/zephyr-sys/build.rs `, which ``cargo `` knows to run at build time will
25
+ :file: `lib/rust/zephyr-sys/build.rs `, which ``cargo `` knows to run at build time, will
26
26
generate the bindings for the particular build of Zephyr being used by the current Rust application.
27
27
28
28
These bindings will be made available in the ``zephyr-sys `` crate, as well as under ``zephyr::raw ``.
29
29
30
30
Using the Bindings
31
31
******************
32
32
33
- In general, using direct bindings to C function from Rust is a bit more difficult than calling them
33
+ In general, using direct bindings to C functions from Rust is a bit more difficult than calling them
34
34
from C. Although all of these calls are considered "unsafe", and must be placed in an ``unsafe ``
35
- block, the rust language has stricter constraints on what is allowed, even by unsafe code. Although
36
- the intent of the Rust on Zephyr project is to allow full use of Zephyr, without needing to resort
37
- to unsafe code, it is understandable that this implementation will be incomplete, and some
38
- applications may require resorting to, what is sometimes referred to as "The Dark Arts". The
39
- `Rustinomicon `_ is a good resource for those wishing to delve into this area.
35
+ block, the Rust language has stricter constraints on what is allowed, even by unsafe code. The
36
+ intent of supporting the Rust Language on Zephyr project is to allow full use of Zephyr, without
37
+ needing to resort to unsafe code, it is understandable that this implementation will be incomplete,
38
+ and some applications may require resorting to, what is sometimes referred to as "The Dark Arts".
39
+ The `Rustinomicon `_ is a good resource for those wishing to delve into this area.
40
40
41
41
.. _Rustinomicon : https://doc.rust-lang.org/nomicon/
42
42
0 commit comments