1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-22 14:59:37 +02:00

Update Chromium Rust policy (#2530)

Co-authored-by: Dustin J. Mitchell <djmitche@google.com>
This commit is contained in:
Adrian Taylor 2024-12-28 21:08:34 +00:00 committed by GitHub
parent 7f0c591b0b
commit 665300e373
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,16 +1,29 @@
# Chromium Rust policy
Chromium does not yet allow first-party Rust except in rare cases as approved by
Chromium's
[Area Tech Leads](https://source.chromium.org/chromium/chromium/src/+/main:ATL_OWNERS).
Chromium's Rust policy can be found
[here](https://source.chromium.org/chromium/chromium/src/+/main:docs/rust.md;l=22).
Rust can be used for both first-party and third-party code.
Chromium's policy on third party libraries is outlined
[here](https://chromium.googlesource.com/chromium/src/+/main/docs/adding_to_third_party.md#rust) -
Rust is allowed for third party libraries under various circumstances, including
if they're the best option for performance or for security.
Using Rust for pure first-party code looks like this:
Very few Rust libraries directly expose a C/C++ API, so that means that nearly
all such libraries will require a small amount of first-party glue code.
```bob
"C++" Rust
.- - - - - - - - - -. .- - - - - - - - - - -.
: : : :
: Existing Chromium : : Chromium Rust :
: "C++" : : code :
: +---------------+ : : +----------------+ :
: | | : : | | :
: | o-----+-+-----------+-+-> | :
: | | : Language : | | :
: +---------------+ : boundary : +----------------+ :
: : : :
`- - - - - - - - - -' `- - - - - - - - - - -'
```
The third-party case is also common. It's likely that you'll also need a small
amount of first-party glue code, because very few Rust libraries directly expose
a C/C++ API.
```bob
"C++" Rust
@ -27,12 +40,9 @@ all such libraries will require a small amount of first-party glue code.
`- - - - - - - - - -' `- - - - - - - - - - - - - - - - - - - - - - -'
```
> First-party Rust glue code for a particular third-party crate should normally
> be kept in `third_party/rust/<crate>/<version>/wrapper`.
Because of this, today's course will be heavily focused on:
The scenario of using a third-party crate is the more complex one, so today's
course will focus on:
- Bringing in third-party Rust libraries ("crates")
- Writing glue code to be able to use those crates from Chromium C++.
If this policy changes over time, the course will evolve to keep up.
- Writing glue code to be able to use those crates from Chromium C++. (The same
techniques are used when working with first-party Rust code).