Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ SPDX-License-Identifier: CC-BY-4.0
- [With C](android/interoperability/with-c.md)
- [A Simple C Library](android/interoperability/with-c/c-library.md)
- [Bindgen](android/interoperability/with-c/bindgen.md)
- [Using the Bindings](android/interoperability/with-c/using-bindings.md)
- [Running Our Binary](android/interoperability/with-c/run-our-binary.md)
- [A Simple Rust Library](android/interoperability/with-c/rust-library.md)
- [Calling Rust from C](android/interoperability/with-c/rust.md)
Expand Down
21 changes: 0 additions & 21 deletions src/android/interoperability/with-c/bindgen.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,9 @@ _interoperability/bindgen/Android.bp_:
{{#include bindgen/Android.bp:libbirthday_bindgen}}
```

Finally, we can use the bindings in our Rust program:

_interoperability/bindgen/Android.bp_:

```javascript
{{#include bindgen/Android.bp:print_birthday_card}}
```

_interoperability/bindgen/main.rs_:

```rust,compile_fail
# // Copyright 2022 Google LLC
# // SPDX-License-Identifier: Apache-2.0
#
{{#include bindgen/main.rs:main}}
```

<details>

- The Android build rules will automatically call `bindgen` for you behind the
scenes.

- Notice that the Rust code in `main` is still hard to write. It is good
practice to encapsulate the output of `bindgen` in a Rust library which
exposes a safe interface to caller.

</details>
31 changes: 31 additions & 0 deletions src/android/interoperability/with-c/using-bindings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
Copyright 2026 Google LLC
SPDX-License-Identifier: CC-BY-4.0
-->

# Using the Bindings

Finally, we can use the bindings in our Rust program:

_interoperability/bindgen/Android.bp_:

```javascript
{{#include bindgen/Android.bp:print_birthday_card}}
```

_interoperability/bindgen/main.rs_:

```rust,compile_fail
# // Copyright 2022 Google LLC
# // SPDX-License-Identifier: Apache-2.0
#
{{#include bindgen/main.rs:main}}
```

<details>

- Notice that the Rust code in `main` is still hard to write. It is good
practice to encapsulate the output of `bindgen` in a Rust library which
exposes a safe interface to caller.

</details>
Loading